Skip to content

Commit a6d0a87

Browse files
Address review: do not treat an installed prerelease as satisfying a stable request
When Prerelease is false, exclude prereleases from the already-installed check so a machine with only prerelease builds installed still installs a stable version instead of failing resolution.
1 parent e76e997 commit a6d0a87

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/init.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ process {
3333
Write-Verbose "Filtering by version: $Version"
3434
$installedParams['Version'] = $Version
3535
}
36-
$alreadyInstalled = Get-InstalledPSResource @installedParams
36+
$alreadyInstalled = @(Get-InstalledPSResource @installedParams)
37+
if (-not $Prerelease) {
38+
# A prerelease already on disk must not count as "already installed" for a stable request,
39+
# otherwise installation is skipped and resolution later fails with only a prerelease present.
40+
$alreadyInstalled = @($alreadyInstalled | Where-Object { [string]::IsNullOrWhiteSpace($_.Prerelease) })
41+
}
3742

3843
if ($showInit) {
3944
Write-Output 'Already installed:'

0 commit comments

Comments
 (0)