forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasdf-exec
More file actions
executable file
·67 lines (53 loc) · 1.83 KB
/
Copy pathasdf-exec
File metadata and controls
executable file
·67 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
source $(dirname $(dirname $(dirname $0)))/lib/utils.sh
plugin_name=$1
executable_path=$2
plugin_path=$(get_plugin_path $plugin_name)
check_if_plugin_exists $plugin_path
full_version=$(get_preset_version_for $plugin_name)
if [ "$full_version" == "" ]; then
echo "No version set for ${plugin_name}"
exit -1
fi
IFS=' ' read -a versions <<< "$full_version"
for version in "${versions[@]}"; do
IFS=':' read -a version_info <<< "$version"
if [ "${version_info[0]}" = "ref" ]; then
install_type="${version_info[0]}"
version="${version_info[1]}"
install_path=$(get_install_path $plugin_name $install_type $version)
elif [ "${version_info[0]}" = "path" ]; then
# This is for people who have the local source already compiled
# Like those who work on the language, etc
# We'll allow specifying path:/foo/bar/project in .tool-versions
# And then use the binaries there
install_type="path"
version="path"
install_path="${version_info[1]}"
else
install_type="version"
version="${version_info[0]}"
install_path=$(get_install_path $plugin_name $install_type $version)
fi
if [ ! -d $install_path ]; then
echo "$plugin_name $version not installed"
exit 1
fi
if [ -f ${install_path}/${executable_path} ]; then
if [ -f ${plugin_path}/bin/exec-env ]; then
export ASDF_INSTALL_TYPE=$install_type
export ASDF_INSTALL_VERSION=$version
export ASDF_INSTALL_PATH=$install_path
source ${plugin_path}/bin/exec-env
# unset everything, we don't want to pollute
unset ASDF_INSTALL_TYPE
unset ASDF_INSTALL_VERSION
unset ASDF_INSTALL_PATH
exec ${install_path}/${executable_path} "${@:3}"
else
exec ${install_path}/${executable_path} "${@:3}"
fi
fi
done
echo "No such command in $full_version of $plugin_name"
exit 1