Fix which for when "system" version is present

This commit is contained in:
Daniel Perez 2018-11-29 00:31:31 +00:00
parent 11882c1151
commit 2eae89c432
2 changed files with 13 additions and 1 deletions

View File

@ -9,6 +9,9 @@ which_command() {
# shellcheck disable=SC2162 # shellcheck disable=SC2162
IFS=' ' read -a versions <<< "$full_version" IFS=' ' read -a versions <<< "$full_version"
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
if [ "$version" = "system" ]; then
continue
fi
if [ -f "${plugin_path}/bin/exec-path" ]; then if [ -f "${plugin_path}/bin/exec-path" ]; then
cmd=$(basename "$executable_path") cmd=$(basename "$executable_path")
install_path=$(find_install_path "$plugin_name" "$version") install_path=$(find_install_path "$plugin_name" "$version")
@ -31,4 +34,4 @@ which_command() {
exit 1 exit 1
fi fi
exit 0 exit 0
} }

View File

@ -35,6 +35,15 @@ teardown() {
[ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/subdir/other_bin" ] [ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/subdir/other_bin" ]
} }
@test "which should ignore system version" {
echo 'dummy system 1.0' > $PROJECT_DIR/.tool-versions
cd $PROJECT_DIR
run which_command "other_bin"
[ "$status" -eq 0 ]
[ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/subdir/other_bin" ]
}
@test "which should inform when no binary is found" { @test "which should inform when no binary is found" {
cd $PROJECT_DIR cd $PROJECT_DIR