diff --git a/nvm.sh b/nvm.sh index 678ab64..bbeba05 100644 --- a/nvm.sh +++ b/nvm.sh @@ -433,19 +433,20 @@ nvm() { fi provided_version=$1 + if [ -z "$provided_version" ]; then if [ $version_not_provided -ne 1 ]; then nvm_rc_version fi provided_version="$NVM_RC_VERSION" + else + shift fi [ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return VERSION=`nvm_remote_version $provided_version` ADDITIONAL_PARAMETERS='' - shift - while [ $# -ne 0 ] do ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" @@ -494,7 +495,9 @@ nvm() { fi fi - echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" + if [ -n "$ADDITIONAL_PARAMETERS" ]; then + echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" + fi tarball='' sum='' @@ -796,7 +799,7 @@ nvm() { local PROVIDED_VERSION PROVIDED_VERSION="$2" - if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ]; then + if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version $PROVIDED_VERSION)" = "$(nvm_ls_current)" ]; then echo 'Can not copy packages from the current version of node.' >&2 return 2 fi diff --git a/test/fast/Listing versions/teardown b/test/fast/Listing versions/teardown old mode 100644 new mode 100755 diff --git "a/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" index 8ae7b29..23bbe38 100755 --- "a/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" +++ "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" @@ -34,7 +34,7 @@ function cleanup() { function runNvmUse() { mkdir ../../${TEST_NODE_VERSION} - nvm use ${TEST_NODE_VERSION} &> /dev/null + nvm use ${TEST_NODE_VERSION} > /dev/null 2>&1 rmdir ../../${TEST_NODE_VERSION} } diff --git "a/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" "b/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" old mode 100644 new mode 100755 index 2e0d058..e296e7c --- "a/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" +++ "b/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" @@ -2,11 +2,15 @@ die () { echo $@ ; exit 1; } -. ../../nvm.sh +. ../../../nvm.sh -local EXPECTED_MSG="Can not copy packages from the current version of node." -[ "$(nvm use 0.10.28 && nvm copy-packages 0.10.28 2&>1)" = "$EXPECTED_MSG" ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right message' +nvm use 0.10.28 > /dev/null -$(nvm use 0.10.28 && nvm copy-packages 0.10.28) -[ $? = 2 ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right error code' +EXPECTED_MSG="Can not copy packages from the current version of node." +ACTUAL_MSG="$(nvm copy-packages 0.10.28 2>&1 > /dev/null)" +[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'" + +EXPECTED_ERROR_CODE="2" +ACTUAL_ERROR_CODE="$(nvm copy-packages 0.10.28 > /dev/null 2>&1 ; echo $?)" +[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'" diff --git a/test/slow/nvm install/install version specified in .nvmrc from binary b/test/slow/nvm install/install version specified in .nvmrc from binary old mode 100644 new mode 100755 index dec2fe1..7758afe --- a/test/slow/nvm install/install version specified in .nvmrc from binary +++ b/test/slow/nvm install/install version specified in .nvmrc from binary @@ -9,7 +9,7 @@ NVM_TEST_VERSION=v0.10.7 [ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION # Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc +echo "$NVM_TEST_VERSION" > .nvmrc nvm install diff --git a/test/slow/nvm install/install version specified in .nvmrc from source b/test/slow/nvm install/install version specified in .nvmrc from source old mode 100644 new mode 100755 index 6910228..189fffa --- a/test/slow/nvm install/install version specified in .nvmrc from source +++ b/test/slow/nvm install/install version specified in .nvmrc from source @@ -9,7 +9,7 @@ NVM_TEST_VERSION=v0.10.7 [ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION # Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc +echo "$NVM_TEST_VERSION" > .nvmrc nvm install -s