Skip to content

Commit

Permalink
fix(Versions): Better array handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed May 17, 2020
1 parent 0da20a0 commit 958e0ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 958e0ef

Please sign in to comment.