Add nvm_validate_implicit_alias
parent
f0471acbf5
commit
fcdd1ef431
7
nvm.sh
7
nvm.sh
|
@ -368,6 +368,13 @@ nvm_print_versions() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_validate_implicit_alias() {
|
||||||
|
if [ "_$1" != "_stable" ] && [ "_$1" != "_unstable" ]; then
|
||||||
|
echo "Only implicit aliases 'stable' and 'unstable' are supported." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
nvm() {
|
nvm() {
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXPECTED_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
||||||
|
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||||
|
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias without stable|unstable had wrong exit code: expected 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
|
||||||
|
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
|
||||||
|
|
Loading…
Reference in New Issue