From 6fb94e0dab013b8964f7ad6ecc8c49f93117e28c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 4 May 2016 00:33:56 -0700 Subject: [PATCH] =?UTF-8?q?[fix]=20`nvm=20exec`:=20show=20=E2=80=9Cio.js?= =?UTF-8?q?=E2=80=9D=20for=20io.js=20versions.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvm.sh | 8 ++++- ...eamble works and respects \"silent\" flag" | 31 +++++++++++++++++++ .../Running \"nvm exec 0.x\" should work" | 2 +- ..."nvm exec\" should pick up .nvmrc version" | 2 +- test/slow/nvm exec/setup_dir | 2 +- test/slow/nvm exec/teardown_dir | 2 +- 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 "test/slow/nvm exec/Preamble works and respects \"silent\" flag" diff --git a/nvm.sh b/nvm.sh index c6ee43c..9796582 100755 --- a/nvm.sh +++ b/nvm.sh @@ -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" ) diff --git "a/test/slow/nvm exec/Preamble works and respects \"silent\" flag" "b/test/slow/nvm exec/Preamble works and respects \"silent\" flag" new file mode 100755 index 0000000..a4153ab --- /dev/null +++ "b/test/slow/nvm exec/Preamble works and respects \"silent\" flag" @@ -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'" + diff --git "a/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" "b/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" index bf036cf..537fafe 100755 --- "a/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" +++ "b/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" @@ -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" diff --git "a/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" "b/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" index 203cd9a..3cc0cb8 100755 --- "a/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" +++ "b/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" @@ -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 diff --git a/test/slow/nvm exec/setup_dir b/test/slow/nvm exec/setup_dir index a5fc4bc..d858b23 100755 --- a/test/slow/nvm exec/setup_dir +++ b/test/slow/nvm exec/setup_dir @@ -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 diff --git a/test/slow/nvm exec/teardown_dir b/test/slow/nvm exec/teardown_dir index 789456c..d9e0dc6 100755 --- a/test/slow/nvm exec/teardown_dir +++ b/test/slow/nvm exec/teardown_dir @@ -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