asdf/lib/commands/uninstall.sh

39 lines
969 B
Bash
Raw Normal View History

2015-05-17 00:46:56 -07:00
uninstall_command() {
local plugin_name=$1
2015-05-17 00:46:56 -07:00
local full_version=$2
2017-09-04 10:04:56 -07:00
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")
2015-05-07 22:58:07 -07:00
2017-09-04 10:04:56 -07:00
check_if_plugin_exists "$plugin_name"
2015-05-07 22:58:07 -07:00
2017-09-04 10:04:56 -07:00
IFS=':' read -r -a version_info <<< "$full_version"
2015-05-21 21:47:27 -07:00
if [ "${version_info[0]}" = "ref" ]; then
2015-05-17 00:46:56 -07:00
local install_type="${version_info[0]}"
local version="${version_info[1]}"
else
local install_type="version"
local version="${version_info[0]}"
fi
2015-05-07 22:58:07 -07:00
2017-09-04 10:04:56 -07:00
local install_path
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
2015-05-07 22:58:07 -07:00
2017-09-04 10:04:56 -07:00
if [ ! -d "$install_path" ]; then
2015-05-17 00:46:56 -07:00
display_error "No such version"
exit 1
fi
2015-05-16 21:28:14 -07:00
remove_shims_for_version "$plugin_name" "$full_version"
2017-09-04 10:04:56 -07:00
if [ -f "${plugin_path}/bin/uninstall" ]; then
2015-05-21 22:17:44 -07:00
(
export ASDF_INSTALL_TYPE=$install_type
export ASDF_INSTALL_VERSION=$version
export ASDF_INSTALL_PATH=$install_path
2017-09-04 10:04:56 -07:00
bash "${plugin_path}/bin/uninstall"
2015-05-21 22:17:44 -07:00
)
2015-05-17 00:46:56 -07:00
else
2017-09-04 10:04:56 -07:00
rm -rf "$install_path"
2015-05-17 00:46:56 -07:00
fi
}