diff --git a/lib/Versions.ps1 b/lib/Versions.ps1 index 23684a0dbe..53da416428 100644 --- a/lib/Versions.ps1 +++ b/lib/Versions.ps1 @@ -57,8 +57,8 @@ function Get-InstalledVersion { if (Test-Path $appPath -PathType Container) { # TODO: Keep only scoop-install.json $arr = @((Get-ChildItem "$appPath\*\install.json"), (Get-ChildItem "$appPath\*\scoop-install.json")) - $versions = @(($arr | Sort-Object -Property LastWriteTimeUtc).Directory.Name) - $result = $versions | Where-Object { $_ -ne 'current' } + $versions = @(($arr | Sort-Object -Property LastWriteTimeUtc).Directory.Name) | Where-Object { $_ -ne 'current' } + if ($versions.Count -gt 0) { $result = $versions } } return $result diff --git a/lib/uninstall.ps1 b/lib/uninstall.ps1 index 70c8f7cbaa..ca05e1234b 100644 --- a/lib/uninstall.ps1 +++ b/lib/uninstall.ps1 @@ -104,7 +104,7 @@ function Uninstall-ScoopApplication { } } - @(Get-InstalledVersion -AppName $App -Global:$Global) | ForEach-Object { + Get-InstalledVersion -AppName $App -Global:$Global | ForEach-Object { message "Removing older version ($_)." $dir = versiondir $app $_ $Global @@ -118,7 +118,7 @@ function Uninstall-ScoopApplication { } } - if (@(Get-InstalledVersion -AppName $App -Global:$Global).Length -eq 0) { + if ((Get-InstalledVersion -AppName $App -Global:$Global).Count -eq 0) { $appdir = appdir $App $Global try { # if last install failed, the directory seems to be locked and this