11install_command () {
22 local plugin_name=$1
33 local full_version=$2
4+
5+ if [ " $plugin_name " = " " ] && [ " $full_version " = " " ]; then
6+ install_local_tool_versions
7+ else
8+ install_tool_version $plugin_name $full_version
9+ fi
10+ }
11+
12+
13+ install_local_tool_versions () {
14+ if [ -f $( pwd) /.tool-versions ]; then
15+ local asdf_versions_path=$( pwd) /.tool-versions
16+ echo " Reading $asdf_versions_path " >> ~ /.asdf.log
17+
18+ local read_done=false
19+ until $read_done ; do
20+ read tool_line || read_done=true
21+ IFS=' ' read -a tool_info <<< $tool_line
22+ local t_name=$( echo " ${tool_info[0]} " | xargs)
23+ local t_version=$( echo " ${tool_info[1]} " | xargs)
24+
25+ install_command $t_name $t_version
26+ done < $asdf_versions_path
27+ else
28+ echo " Either specify a tool & version in the command"
29+ echo " OR add .tool-versions file in this directory"
30+ exit 1
31+ fi
32+ }
33+
34+
35+ install_tool_version () {
36+ local plugin_name=$1
37+ local full_version=$2
438 local plugin_path=$( get_plugin_path $plugin_name )
539 check_if_plugin_exists $plugin_path
640
41+
742 IFS=' :' read -a version_info <<< " $full_version"
843 if [ " ${version_info[0]} " = " ref" ]; then
944 local install_type=" ${version_info[0]} "
@@ -13,24 +48,24 @@ install_command() {
1348 local version=" ${version_info[0]} "
1449 fi
1550
51+
1652 local install_path=$( get_install_path $plugin_name $install_type $version )
1753 if [ -d $install_path ]; then
1854 echo " $plugin_name $full_version is already installed"
19- echo " To uninstall it run: asdf uninstall $plugin_name $full_version "
20- exit 0
21- fi
22-
23- (
24- export ASDF_INSTALL_TYPE=$install_type
25- export ASDF_INSTALL_VERSION=$version
26- export ASDF_INSTALL_PATH=$install_path
27- mkdir $install_path
28- bash ${plugin_path} /bin/install
29- )
30- local exit_code=$?
31- if [ $exit_code -eq 0 ]; then
32- reshim_command $plugin_name $full_version
3355 else
34- exit $exit_code
56+ (
57+ export ASDF_INSTALL_TYPE=$install_type
58+ export ASDF_INSTALL_VERSION=$version
59+ export ASDF_INSTALL_PATH=$install_path
60+ mkdir $install_path
61+ bash ${plugin_path} /bin/install
62+ )
63+
64+ local exit_code=$?
65+ if [ $exit_code -eq 0 ]; then
66+ reshim_command $plugin_name $full_version
67+ else
68+ exit $exit_code
69+ fi
3570 fi
3671}
0 commit comments