mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-28 12:41:34 +00:00
[Fix] nvm install
: show proper version in .nvmrc
install instructions
This commit is contained in:

committed by
Jordan Harband

parent
7d86701067
commit
9e884b8d7b
@@ -7,10 +7,10 @@ die () { echo "$@" ; exit 1; }
|
||||
|
||||
EXPECTED_OUTPUT='N/A: version "v0.2" is not yet installed.
|
||||
|
||||
You need to run "nvm install 0.2" to install it before using it.'
|
||||
You need to run `nvm install 0.2` to install and use it.'
|
||||
[ "_$(nvm run 0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
|
||||
|
||||
EXPECTED_OUTPUT='N/A: version "iojs-v0.2" is not yet installed.
|
||||
|
||||
You need to run "nvm install iojs-0.2" to install it before using it.'
|
||||
You need to run `nvm install iojs-0.2` to install and use it.'
|
||||
[ "_$(nvm run iojs-0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"
|
||||
|
@@ -10,3 +10,16 @@ echo "0.10.7" > .nvmrc
|
||||
[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the .nvmrc version"
|
||||
|
||||
[ "$(nvm run --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm run\` failed to print out the \"found in .nvmrc\" message"
|
||||
|
||||
|
||||
echo "foo" > .nvmrc
|
||||
|
||||
# running nvm run with .nvmrc should not print the version information when not installed
|
||||
OUTPUT="$(nvm run --version 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT="Found '$PWD/.nvmrc' with version <foo>
|
||||
N/A: version \"foo\" is not yet installed.
|
||||
|
||||
You need to run \`nvm install\` to install and use the node version specified in \`.nvmrc\`."
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm use' with nvmrc to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm use' with nvmrc to exit with 1, got $EXIT_CODE"
|
||||
|
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
echo "foo" > .nvmrc
|
||||
|
||||
# running nvm use with .nvmrc should not print the version information
|
||||
OUTPUT="$(nvm use 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT="Found '$PWD/.nvmrc' with version <foo>
|
||||
N/A: version \"foo\" is not yet installed.
|
||||
|
||||
You need to run \`nvm install\` to install and use the node version specified in \`.nvmrc\`."
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm use' with nvmrc to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "expected 'nvm use' with nvmrc to exit with 3, got $EXIT_CODE"
|
||||
|
||||
# --silent should not print anything
|
||||
OUTPUT=$(nvm use --silent)
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent' output was not silenced to '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
rm .nvmrc
|
Reference in New Issue
Block a user