mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Fix current behavior when multiple versions of a plugin are set
This commit is contained in:
parent
953e32ae34
commit
18587d4d6f
@ -7,19 +7,22 @@ plugin_current_command() {
|
||||
search_path=$(pwd)
|
||||
local version_and_path
|
||||
version_and_path=$(find_version "$plugin_name" "$search_path")
|
||||
local version
|
||||
version=$(cut -d '|' -f 1 <<< "$version_and_path");
|
||||
local full_version
|
||||
full_version=$(cut -d '|' -f 1 <<< "$version_and_path");
|
||||
local version_file_path
|
||||
version_file_path=$(cut -d '|' -f 2 <<< "$version_and_path");
|
||||
|
||||
check_if_version_exists "$plugin_name" "$version"
|
||||
IFS=' ' read -r -a versions <<< "$full_version"
|
||||
for version in $versions; do
|
||||
check_if_version_exists "$plugin_name" "$version"
|
||||
done
|
||||
check_for_deprecated_plugin "$plugin_name"
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
if [ -z "$full_version" ]; then
|
||||
printf "%s\\n" "$(display_no_version_set "$plugin_name")"
|
||||
exit 126
|
||||
else
|
||||
printf "%-8s (set by %s)\\n" "$version" "$version_file_path"
|
||||
printf "%-8s (set by %s)\\n" "$full_version" "$version_file_path"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,16 @@ teardown() {
|
||||
[ "$output" = "nightly-2000-01-01 (set by $PROJECT_DIR/.tool-versions)" ]
|
||||
}
|
||||
|
||||
@test "current should handle multiple versions" {
|
||||
cd $PROJECT_DIR
|
||||
echo "dummy 1.2.0 1.1.0" >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
run current_command "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "1.2.0 1.1.0 (set by $PROJECT_DIR/.tool-versions)" ]
|
||||
}
|
||||
|
||||
|
||||
@test "current should derive from the legacy file if enabled" {
|
||||
cd $PROJECT_DIR
|
||||
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||
|
Loading…
Reference in New Issue
Block a user