aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
236 stars 78 forks source link

Remove unnecessary Find-Module call in AWS.Tools.Installer #83

Closed tlindsay42 closed 4 years ago

tlindsay42 commented 4 years ago

Remove an unnecessary Find-Module call in AWS.Tools.Installer.

Expected Behavior

The PowerShell Gallery should not be queried again after selecting the version to install.

Current Behavior

When multiple versions are found for the specified modules, the minimum version is selected, and then another series of Find-Module is run to query the PowerShell Gallery for each specified module, which is unnecessary and slow. If the intent is to test whether the selected version is supported for all specified modules, this could be tested using the module object array in the $savedModules variable that was populated immediately before.

Possible Solution

Remove the following code block in AWS.Tools.Installer.psm1:

            $findModuleParams = @{
                RequiredVersion = $versionToInstall
                Repository      = 'PSGallery'
                ErrorAction     = 'Stop'
            }
            $savedModules = $Name | ForEach-Object { Find-Module -Name $_ @findModuleParams @proxyParams }

Context

Slows things down unnecessarily when multiple versions are found for the requested modules.

Your Environment

Include as many relevant details about the environment where the bug was discovered.