diff --git a/ModuleFast.psm1 b/ModuleFast.psm1 index b319dba..5b2bb0b 100644 --- a/ModuleFast.psm1 +++ b/ModuleFast.psm1 @@ -1673,7 +1673,7 @@ function Find-LocalModule { if ($Update -and ($ModuleSpec.Max -ne $candidateVersion)) { Write-Debug "${ModuleSpec}: Skipping $candidateVersion because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely." #We can use this ref later to find out if our best remote version matches what is installed without having to read the manifest again - if ($BestCandidate -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) { + if ($bestCandidate.Value[$moduleSpec] -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) { Write-Debug "${ModuleSpec}: New Best Candidate Version $($manifestCandidate.ModuleVersion)" $BestCandidate.Value.Add($moduleSpec, $manifestCandidate) } diff --git a/ModuleFast.tests.ps1 b/ModuleFast.tests.ps1 index bab804f..de83f0b 100644 --- a/ModuleFast.tests.ps1 +++ b/ModuleFast.tests.ps1 @@ -478,6 +478,12 @@ Describe 'Install-ModuleFast' -Tag 'E2E' { Install-ModuleFast @imfParams 'Az.Compute', 'Az.CosmosDB' -Update -Plan | Should -BeNullOrEmpty } + It 'Updates if multiple local versions installed' { + Install-ModuleFast @imfParams 'Plaster=1.1.1' + Install-ModuleFast @imfParams 'Plaster=1.1.3' + $actual = Install-ModuleFast @imfParams 'Plaster' -Update -PassThru + $actual.ModuleVersion | Should -Be '1.1.4' + } It 'Updates only dependent module that requires update' { Install-ModuleFast @imfParams @{ ModuleName = 'Az.Accounts'; RequiredVersion = '2.10.2' }