Allow `--silent` option to `nvm use` to be in any position.
parent
6e894520ec
commit
643365a948
18
nvm.sh
18
nvm.sh
|
@ -1557,19 +1557,27 @@ nvm() {
|
||||||
local PROVIDED_VERSION
|
local PROVIDED_VERSION
|
||||||
local NVM_USE_SILENT
|
local NVM_USE_SILENT
|
||||||
NVM_USE_SILENT=0
|
NVM_USE_SILENT=0
|
||||||
if [ "$2" = '--silent' ]; then
|
shift # remove "use"
|
||||||
NVM_USE_SILENT=1
|
while [ $# -ne 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--silent) NVM_USE_SILENT=1 ;;
|
||||||
|
*)
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
PROVIDED_VERSION="$1"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift
|
shift
|
||||||
fi
|
done
|
||||||
|
|
||||||
if [ $# -eq 1 ]; then
|
if [ -z "$PROVIDED_VERSION" ]; then
|
||||||
nvm_rc_version
|
nvm_rc_version
|
||||||
if [ -n "$NVM_RC_VERSION" ]; then
|
if [ -n "$NVM_RC_VERSION" ]; then
|
||||||
PROVIDED_VERSION="$NVM_RC_VERSION"
|
PROVIDED_VERSION="$NVM_RC_VERSION"
|
||||||
VERSION="$(nvm_version "$PROVIDED_VERSION")"
|
VERSION="$(nvm_version "$PROVIDED_VERSION")"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
PROVIDED_VERSION="$2"
|
|
||||||
VERSION="$(nvm_match_version "$PROVIDED_VERSION")"
|
VERSION="$(nvm_match_version "$PROVIDED_VERSION")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,16 @@ EXPECTED_OUTPUT=''
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use foo --silent 2>&1)"
|
||||||
|
EXPECTED_OUTPUT=''
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
||||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup;
|
cleanup;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue