Skip to content

Commit 6fe4e90

Browse files
authored
🐛 Best Candidate comparison by ref not matching correctly
1 parent 7211e53 commit 6fe4e90

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ModuleFast.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ function Find-LocalModule {
16731673
if ($Update -and ($ModuleSpec.Max -ne $candidateVersion)) {
16741674
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."
16751675
#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
1676-
if ($BestCandidate -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) {
1676+
if ($bestCandidate.Value[$moduleSpec] -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) {
16771677
Write-Debug "${ModuleSpec}: New Best Candidate Version $($manifestCandidate.ModuleVersion)"
16781678
$BestCandidate.Value.Add($moduleSpec, $manifestCandidate)
16791679
}

ModuleFast.tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ Describe 'Install-ModuleFast' -Tag 'E2E' {
478478
Install-ModuleFast @imfParams 'Az.Compute', 'Az.CosmosDB' -Update -Plan
479479
| Should -BeNullOrEmpty
480480
}
481+
It 'Updates if multiple local versions installed' {
482+
Install-ModuleFast @imfParams 'Plaster=1.1.1'
483+
Install-ModuleFast @imfParams 'Plaster=1.1.3'
484+
$actual = Install-ModuleFast @imfParams 'Plaster' -Update -PassThru
485+
$actual.ModuleVersion | Should -Be '1.1.4'
486+
}
481487

482488
It 'Updates only dependent module that requires update' {
483489
Install-ModuleFast @imfParams @{ ModuleName = 'Az.Accounts'; RequiredVersion = '2.10.2' }

0 commit comments

Comments
 (0)