[Fix] nvm uninstall: only remove aliases that point at the uninstalled version
Matching alias files by substring also removed aliases to longer versions, so uninstalling v20.1.1 deleted an alias to v20.1.10. Each alias's target is now read the way `nvm_alias` reads it, ignoring comments, and in zsh an empty alias directory no longer errors with "no matches found".
This commit is contained in:
2 files changed
+45
-2
No files matched your search
@@ -4874,8 +4874,12 @@ nvm() {
|
||||
nvm_echo "${NVM_SUCCESS_MSG}"
|
||||
|
||||
# rm any aliases that point to uninstalled version.
|
||||
for ALIAS in $(nvm_grep -l -e "${VERSION}" "$(nvm_alias_path)"/* 2>/dev/null); do
|
||||
nvm unalias "$(command basename "${ALIAS}")"
|
||||
nvm_is_zsh && setopt local_options nonomatch
|
||||
local NVM_ALIAS_FILE
|
||||
for NVM_ALIAS_FILE in "$(nvm_alias_path)"/*; do
|
||||
if [ -f "${NVM_ALIAS_FILE}" ] && [ "_$(nvm_print_alias_file "${NVM_ALIAS_FILE}" | command head -n 1)" = "_${VERSION}" ]; then
|
||||
nvm unalias "$(command basename "${NVM_ALIAS_FILE}")"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
"deactivate")
|
||||
|
||||
Reference in new issue
Block a user