RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
285 stars 76 forks source link

improve perf - remove redundant call to Get-PSRepository #58

Closed christianacca closed 6 years ago

christianacca commented 6 years ago

The existing PS commands that accept a repo (eg Install-Module) will already throw a message saying that the repo supplied cannot be found.

Calling Get-PSRepository for each PS repository takes approx. 3 seconds.

So given a requirement.psd1 file with 2 repositories, 6s will be spent validating the repo exists. This time is a waste PS already is checking for this condition.

christianacca commented 6 years ago

Note: I did NOT include this commit in PR https://github.com/RamblingCookieMonster/PSDepend/pull/52 to make it possible to accept/reject each independently.

PR https://github.com/RamblingCookieMonster/PSDepend/pull/52:

This PR on the other hand does make a subtle change to the API contract - it changes the error message that will be thrown when the repository supplied cannot be found:

Before

[$Repository] has not been setup as a valid PowerShell repository.

After

Unable to find repository '[$Repository]'. Use Get-PSRepository to see all available repositories

RamblingCookieMonster commented 6 years ago

Awesome, makes sense to me, thanks!