gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
171 stars 42 forks source link

Importing PowerShellGet twice #366

Open johlju opened 2 years ago

johlju commented 2 years ago

At this line the module PowerShellGet is imported to verify version. https://github.com/gaelcolas/Sampler/blob/d19ef072498ac9df81a3839b0b7a502a066f2235/Resolve-Dependency.ps1#L233

But we already imported it at line: https://github.com/gaelcolas/Sampler/blob/d19ef072498ac9df81a3839b0b7a502a066f2235/Resolve-Dependency.ps1#L171

We should be able to reuse the variable at line 171 (the first import) to evaluate module version here: https://github.com/gaelcolas/Sampler/blob/d19ef072498ac9df81a3839b0b7a502a066f2235/Resolve-Dependency.ps1#L238

gaelcolas commented 2 years ago

As long as the -Force is not used, it's not a big issue as it effectively does nothing but return the module object. That said, if it's not need to run, then it's definitively interested in such PR.