mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-04-03 03:24:51 +08:00
[Fix] nvm install: fix nvm err typo to nvm_err for -s/-b conflict
The error message for using `-s` and `-b` together was calling
`nvm err` (invoking nvm with subcommand "err") instead of the
`nvm_err` helper function, causing the error message to never be displayed and instead showing the help text with exit code 127.
Bug introduced in 4fdef427e4 / #2439
This commit is contained in:
4
nvm.sh
4
nvm.sh
@@ -3439,7 +3439,7 @@ nvm() {
|
||||
shift # consume "-s"
|
||||
nobinary=1
|
||||
if [ $nosource -eq 1 ]; then
|
||||
nvm err '-s and -b cannot be set together since they would skip install from both binary and source'
|
||||
nvm_err '-s and -b cannot be set together since they would skip install from both binary and source'
|
||||
return 6
|
||||
fi
|
||||
;;
|
||||
@@ -3447,7 +3447,7 @@ nvm() {
|
||||
shift # consume "-b"
|
||||
nosource=1
|
||||
if [ $nobinary -eq 1 ]; then
|
||||
nvm err '-s and -b cannot be set together since they would skip install from both binary and source'
|
||||
nvm_err '-s and -b cannot be set together since they would skip install from both binary and source'
|
||||
return 6
|
||||
fi
|
||||
;;
|
||||
|
||||
18
test/fast/Unit tests/nvm install -s and -b conflict
Executable file
18
test/fast/Unit tests/nvm install -s and -b conflict
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
: nvm.sh
|
||||
\. ../../../nvm.sh
|
||||
|
||||
\. ../../common.sh
|
||||
|
||||
EXPECTED_ERR='-s and -b cannot be set together since they would skip install from both binary and source'
|
||||
|
||||
try_err nvm install -s -b 0.10.0
|
||||
[ "${CAPTURED_EXIT_CODE}" = "6" ] || die "Expected exit code 6 for -s -b, got ${CAPTURED_EXIT_CODE}"
|
||||
[ "${CAPTURED_STDERR}" = "${EXPECTED_ERR}" ] || die "Expected >${EXPECTED_ERR}<, got >${CAPTURED_STDERR}<"
|
||||
|
||||
try_err nvm install -b -s 0.10.0
|
||||
[ "${CAPTURED_EXIT_CODE}" = "6" ] || die "Expected exit code 6 for -b -s, got ${CAPTURED_EXIT_CODE}"
|
||||
[ "${CAPTURED_STDERR}" = "${EXPECTED_ERR}" ] || die "Expected >${EXPECTED_ERR}<, got >${CAPTURED_STDERR}<"
|
||||
Reference in New Issue
Block a user