[fix] `nvm exec`: show “io.js” for io.js versions.

Jordan Harband 2016-05-04 00:33:56 -07:00
parent 0dd2846215
commit 6fb94e0dab
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
6 changed files with 42 additions and 5 deletions

8
nvm.sh
View File

@ -2225,7 +2225,13 @@ nvm() {
return $EXIT_CODE
fi
[ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)"
if [ "${NVM_SILENT:-0}" != '1' ]; then
if nvm_is_iojs_version "$VERSION"; then
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)"
else
echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)"
fi
fi
NODE_VERSION="$VERSION" "$NVM_DIR/nvm-exec" "$@"
;;
"ls" | "list" )

View File

@ -0,0 +1,31 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm use 0.10
NPM_VERSION_TEN="$(npm --version)"
NODE_VERSION_TEN="$(node --version)"
nvm use 1.0.0 && [ "$(node --version)" = "v1.0.0" ] || die "\`nvm use\` failed!"
NPM_VERSION_ONE="$(npm --version)"
OUTPUT="$(nvm exec 0.10 npm --version)"
EXPECTED_OUTPUT="Running node ${NODE_VERSION_TEN} (npm v${NPM_VERSION_TEN})
${NPM_VERSION_TEN}"
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "\`nvm exec\` failed to report node preamble; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm exec --silent 0.10 npm --version | head -1)"
EXPECTED_OUTPUT="${NPM_VERSION_TEN}"
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "\`nvm exec --silent\` failed to node suppress preamble; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm exec 1 npm --version)"
EXPECTED_OUTPUT="Running io.js v1.0.0 (npm v${NPM_VERSION_ONE})
${NPM_VERSION_ONE}"
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "\`nvm exec\` failed to report io.js preamble; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm exec --silent 1 npm --version | head -1)"
EXPECTED_OUTPUT="${NPM_VERSION_ONE}"
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "\`nvm exec --silent\` failed to suppress io.js preamble; expected '$EXPECTED_OUTPUT', got '$OUTPUT'"

View File

@ -8,7 +8,7 @@ nvm use 0.10
NPM_VERSION_TEN="$(npm --version)"
TEST_STRING="foo bar"
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
nvm use 1.0.0 && [ "$(node --version)" = "v1.0.0" ] || die "\`nvm use\` failed!"
[ "$(nvm exec 0.10 npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "`nvm exec` failed to run with the correct version"

View File

@ -7,7 +7,7 @@ die () { echo $@ ; exit 1; }
nvm use 0.10.7
NPM_VERSION_TEN="$(npm --version)"
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
nvm use 1.0.0 && [ "$(node --version)" = "v1.0.0" ] || die "\`nvm use\` failed!"
echo "0.10.7" > .nvmrc

View File

@ -2,7 +2,7 @@
. ../../../nvm.sh
nvm install 0.10.7
nvm install 0.11.7
nvm install 1.0.0
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak

View File

@ -3,7 +3,7 @@
. ../../../nvm.sh
nvm deactivate
nvm uninstall v0.10.7
nvm uninstall v0.11.7
nvm uninstall v1.0.0
rm .nvmrc