Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: latest --all correctly report plugins as missing #1118

Merged
merged 2 commits into from Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions help.txt
Expand Up @@ -40,6 +40,8 @@ asdf global <name> latest[:<version>] Set the package local version to the
asdf shell <name> <version> Set the package version to
`ASDF_${LANG}_VERSION` in the current shell
asdf latest <name> [<version>] Show latest stable version of a package
asdf latest --all Show latest stable version of all the
packages and if they are installed
asdf list <name> [version] List installed versions of a package and
optionally filter the versions
asdf list all <name> [<version>] List all versions of a package and
Expand Down
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 ]
}