2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
|
|
|
|
2020-03-02 10:44:31 -07:00
|
|
|
# shellcheck source=lib/commands/reshim.bash
|
2021-05-21 09:03:06 -07:00
|
|
|
. "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
|
2019-11-27 01:24:29 -07:00
|
|
|
|
2015-05-17 00:46:56 -07:00
|
|
|
uninstall_command() {
|
2015-05-26 23:46:17 -07:00
|
|
|
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
|
|
|
|
2019-01-19 12:48:21 -07:00
|
|
|
asdf_run_hook "pre_asdf_uninstall_${plugin_name}" "$full_version"
|
2017-07-26 13:00:55 -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
|
2021-07-29 15:44:14 -07:00
|
|
|
"${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
|
2019-01-19 12:48:21 -07:00
|
|
|
|
|
|
|
asdf_run_hook "post_asdf_uninstall_${plugin_name}" "$full_version"
|
2015-05-17 00:46:56 -07:00
|
|
|
}
|
2019-11-27 01:24:29 -07:00
|
|
|
|
|
|
|
remove_shims_for_version() {
|
|
|
|
local plugin_name=$1
|
|
|
|
local full_version=$2
|
|
|
|
for shim_path in $(plugin_shims "$plugin_name" "$full_version"); do
|
|
|
|
remove_shim_for_version "$plugin_name" "$full_version" "$shim_path"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
uninstall_command "$@"
|