diff --git a/nvm.sh b/nvm.sh index b1cf64c..0a656da 100755 --- a/nvm.sh +++ b/nvm.sh @@ -3906,7 +3906,7 @@ nvm() { nvm_echo "${NVM_SUCCESS_MSG}" # rm any aliases that point to uninstalled version. - for ALIAS in $(nvm_grep -l "${VERSION}" "$(nvm_alias_path)/*" 2>/dev/null); do + for ALIAS in $(nvm_grep -l "${VERSION}" "$(nvm_alias_path)"/* 2>/dev/null); do nvm unalias "$(command basename "${ALIAS}")" done ;; diff --git a/test/fast/Running 'nvm uninstall' should clean up aliases pointing to uninstalled version b/test/fast/Running 'nvm uninstall' should clean up aliases pointing to uninstalled version new file mode 100755 index 0000000..58f23bd --- /dev/null +++ b/test/fast/Running 'nvm uninstall' should clean up aliases pointing to uninstalled version @@ -0,0 +1,24 @@ +#!/bin/sh + +die() { echo "$@" >&2; exit 1; } + +set -ex + +: nvm.sh +\. ../../nvm.sh +\. ../common.sh + +make_fake_node v0.0.1 + +nvm alias test_alias v0.0.1 + +# Verify alias was created +[ -f "$(nvm_alias_path)/test_alias" ] || die "alias file should exist before uninstall" + +nvm uninstall v0.0.1 + +# Verify the version directory was removed +[ ! -d "$(nvm_version_path v0.0.1)" ] || die "version directory should be removed" + +# Verify the alias was cleaned up +[ ! -f "$(nvm_alias_path)/test_alias" ] || die "alias file should be removed after uninstalling the version it points to"