[Docs] `unalias`: add more specific error message for builtin aliases
parent
cc0750eb5d
commit
02997b0753
12
nvm.sh
12
nvm.sh
|
@ -3335,6 +3335,18 @@ nvm() {
|
|||
nvm_err 'Aliases in subdirectories are not supported.'
|
||||
return 1
|
||||
fi
|
||||
|
||||
local NVM_IOJS_PREFIX
|
||||
local NVM_NODE_PREFIX
|
||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||
NVM_NODE_PREFIX="$(nvm_node_prefix)"
|
||||
case "$1" in
|
||||
"stable" | "unstable" | "${NVM_IOJS_PREFIX}" | "${NVM_NODE_PREFIX}" | "system")
|
||||
nvm_err "${1-} is a default (built-in) alias and cannot be deleted."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
[ ! -f "${NVM_ALIAS_DIR}/${1-}" ] && nvm_err "Alias ${1-} doesn't exist!" && return
|
||||
local NVM_ALIAS_ORIGINAL
|
||||
NVM_ALIAS_ORIGINAL="$(nvm_alias "${1}")"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
OUTPUT="$(nvm unalias node 2>&1)"
|
||||
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias stable 2>&1)"
|
||||
EXPECTED_OUTPUT="stable is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias unstable 2>&1)"
|
||||
EXPECTED_OUTPUT="unstable is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias iojs 2>&1)"
|
||||
EXPECTED_OUTPUT="iojs is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm unalias system 2>&1)"
|
||||
EXPECTED_OUTPUT="system is a default (built-in) alias and cannot be deleted."
|
||||
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
Loading…
Reference in New Issue