Skip to content

Commit

Permalink
fix: latest --all correctly reports uninstalled plugins as missing
Browse files Browse the repository at this point in the history
Fixes the bug reported at asdf-vm#1096.
  • Loading branch information
threkk committed Dec 8, 2021
1 parent 42a2321 commit a08cadc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/commands/command-latest.bash
Expand Up @@ -73,7 +73,7 @@ latest_all() {
local installed_versions
installed_versions=$(list_installed_versions "$plugin_name")

if ! printf '%s\n' "$installed_versions" | grep -q "^$version\$"; then
if [ -n "$installed_versions" ] && printf '%s\n' "$installed_versions" | grep -q "^$version\$"; then
installed_status="installed"
fi
printf "%s\\t%s\\t%s\\n" "$plugin_name" "$version" "$installed_status"
Expand Down
11 changes: 10 additions & 1 deletion test/latest_command.bats
Expand Up @@ -64,7 +64,16 @@ teardown() {
#### latest --all ####
################################
@test "[latest_command - all plugins] shows the latest stable version of all plugins" {
run asdf install dummy 2.0.0
run asdf install legacy-dummy 1.0.0
run asdf latest --all
[ "$(echo -e "dummy\t2.0.0\tinstalled\nlegacy-dummy\t2.0.0\tinstalled\n")" == "$output" ]
echo "output $output"
[ "$(echo -e "dummy\t2.0.0\tinstalled\nlegacy-dummy\t2.0.0\tmissing\n")" == "$output" ]
[ "$status" -eq 0 ]
}

@test "[latest_command - all plugins] not installed plugin should return missing" {
run asdf latest --all
[ "$(echo -e "dummy\t2.0.0\tmissing\nlegacy-dummy\t2.0.0\tmissing\n")" == "$output" ]
[ "$status" -eq 0 ]
}

0 comments on commit a08cadc

Please sign in to comment.