mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
52 lines
1.3 KiB
Bash
Executable File
52 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source $(dirname $(dirname $(dirname $0)))/lib/utils.sh
|
|
|
|
package=$1
|
|
executable_path=$2
|
|
|
|
plugin_path=$(get_plugin_path $package)
|
|
check_if_plugin_exists $plugin_path
|
|
|
|
full_version=$(get_preset_version_for $package)
|
|
|
|
if [ "$full_version" == "" ]; then
|
|
echo "No version set for ${package}"
|
|
exit -1
|
|
fi
|
|
|
|
|
|
IFS=':' read -a version_info <<< "$full_version"
|
|
if [ "${version_info[0]}" = "tag" ] || [ "${version_info[0]}" = "commit" ]; then
|
|
install_type="${version_info[0]}"
|
|
version="${version_info[1]}"
|
|
install_path=$(get_install_path $package $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 $package $install_type $version)
|
|
fi
|
|
|
|
|
|
if [ -f ${plugin_path}/bin/exec-env ]; then
|
|
exec_env=$(${plugin_path}/bin/exec-env $install_type $version $install_path)
|
|
(
|
|
eval export ${exec_env};
|
|
${install_path}/${executable_path} "${@:3}"
|
|
exit $?
|
|
)
|
|
else
|
|
(
|
|
${install_path}/${executable_path} "${@:3}"
|
|
exit $?
|
|
)
|
|
fi
|