-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that if
npm config get prefix
is set to something outside `n…
…vm`, that `nvm use` refuses to work. Fixes #606.
- Loading branch information
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/slow/nvm use/Running "nvm use" calls "nvm_die_on_prefix"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
die () { echo $@ ; exit 1; } | ||
|
||
. ../../../nvm.sh | ||
|
||
nvm deactivate >/dev/null 2>&1 || die 'deactivate failed' | ||
|
||
nvm_die_on_prefix() { | ||
echo >&2 "| $1 | $2 |" | ||
return 3 | ||
} | ||
|
||
OUTPUT="$(nvm use --silent node)" | ||
EXPECTED_OUTPUT="" | ||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ | ||
|| die "'nvm use --silent node' did not call through to 'nvm_die_on_prefix' and give output '$EXPECTED_OUTPUT'; got '$OUTPUT'" | ||
|
||
EXIT_CODE="$(nvm use --silent node >/dev/null 2>&1; echo $?)" | ||
EXPECTED_CODE="11" | ||
[ "_$EXIT_CODE" = "_$EXPECTED_CODE" ] \ | ||
|| die "'nvm use --silent node' when 'nvm_die_on_prefix' fails did not return '$EXPECTED_CODE'; got '$EXIT_CODE'" |