Browse Source

[Fix] `nvm uninstall`: work around `nomatch` `zsh` option.

Fixes #1228.
master
Jordan Harband 8 years ago
parent
commit
f9e14b7d4d
No known key found for this signature in database GPG Key ID: 64A196AEE0916D55
  1. 15
      nvm.sh
  2. 5
      test/slow/nvm uninstall/Running "nvm uninstall 0.12.6" uninstalls v0.12.6

15
nvm.sh

@ -2041,16 +2041,31 @@ nvm_is_natural_num() {
# Check version dir permissions
nvm_check_file_permissions() {
local ZSH_HAS_NONOMATCH_UNSET
ZSH_HAS_NONOMATCH_UNSET=1
if nvm_has "setopt"; then
ZSH_HAS_NONOMATCH_UNSET="$(set +e ; setopt | nvm_grep nonomatch > /dev/null ; nvm_echo $?)"
setopt nonomatch
fi
for FILE in $1/* $1/.[!.]* $1/..?* ; do
if [ -d "$FILE" ]; then
if ! nvm_check_file_permissions "$FILE"; then
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
setopt nomatch
fi
return 2
fi
elif [ -e "$FILE" ] && [ ! -w "$FILE" ]; then
nvm_err "file is not writable: $(nvm_sanitize_path "$FILE")"
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
setopt nomatch
fi
return 1
fi
done
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
setopt nomatch
fi
return 0
}

5
test/slow/nvm uninstall/Running "nvm uninstall 0.12.6" uninstalls v0.12.6

@ -20,6 +20,11 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
# Switch to another version so we can uninstall
nvm use 0.12.7
# if zsh, set "nomatch" opt to reproduce failure from https://github.com/creationix/nvm/issues/1228
if nvm_has "setopt"; then
setopt nomatch
fi
# Uninstall it
nvm uninstall $NVM_TEST_VERSION

Loading…
Cancel
Save