File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- current_version () {
1+ which_command () {
22 local plugin_name=$1
33
44 check_if_plugin_exists " $plugin_name "
@@ -9,28 +9,18 @@ current_version() {
99 version_and_path=$( find_version " $plugin_name " " $search_path " )
1010 local version
1111 version=$( cut -d ' |' -f 1 <<< " $version_and_path" ) ;
12+ local install_type=" version"
1213
1314 check_if_version_exists " $plugin_name " " $version "
1415 check_for_deprecated_plugin " $plugin_name "
1516
1617 if [ -z " $version " ]; then
1718 display_no_version_set " $plugin_name "
1819 exit 1
19- else
20- echo " $version "
21- exit 0
2220 fi
23- }
24-
25- which_command () {
26- local plugin_name=$1
27- local plugin_path
28- plugin_path=$( get_plugin_path " $plugin_name " )
29- check_if_plugin_exists " $plugin_name "
30- local install_type=" version"
3121
3222 local install_path
33- install_path=$( get_install_path " $plugin_name " " $install_type " " $( current_version " $plugin_name " ) " )
23+ install_path=$( get_install_path " $plugin_name " " $install_type " " $version " )
3424
3525 if [ -d " $install_path " ]; then
3626 echo " $install_path /bin/$plugin_name "
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ load test_helpers
88setup () {
99 setup_asdf_dir
1010 install_dummy_plugin
11+ install_mock_plugin " bazbat"
1112 run install_command dummy 1.0
1213
1314 PROJECT_DIR=$HOME /project
@@ -23,14 +24,22 @@ teardown() {
2324
2425 echo ' dummy 1.0' >> $PROJECT_DIR /.tool-versions
2526
26- run current_version " dummy"
27- [ " $output " = " 1.0" ]
28-
2927 run which_command " dummy"
3028 [ " $status " -eq 0 ]
3129 [ " $output " = " $ASDF_DIR /installs/dummy/1.0/bin/dummy" ]
3230}
3331
32+ @test " which should inform when no version is set" {
33+ cd $PROJECT_DIR
34+
35+ local expected
36+ expected=" No version set for bazbat; please run \` asdf <global | local> bazbat <version>\` "
37+
38+ run which_command " bazbat"
39+ [ " $status " -eq 1 ]
40+ [ " $output " = " $expected " ]
41+ }
42+
3443@test " which should error when the plugin doesn't exist" {
3544 run which_command " foobar"
3645 [ " $status " -eq 1 ]
You can’t perform that action at this time.
0 commit comments