From 44541b416fa35aa88f627caa0bf67a2a99c6948a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 4 Feb 2016 00:26:33 -0800 Subject: [PATCH] [New] After installing, ensure that the default is set. --- nvm.sh | 2 ++ test/installation/node/install from binary | 5 +++++ test/installation/node/install from source | 5 +++++ test/sourcing/setup | 2 ++ 4 files changed, 14 insertions(+) diff --git a/nvm.sh b/nvm.sh index 2f3dc30..1f168d4 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1730,6 +1730,7 @@ nvm() { if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" fi + nvm_ensure_default_set "$provided_version" return $? fi @@ -1775,6 +1776,7 @@ nvm() { fi if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then + nvm_ensure_default_set "$provided_version" if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \ && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" diff --git a/test/installation/node/install from binary b/test/installation/node/install from binary index 3e17e8e..8b9ac48 100755 --- a/test/installation/node/install from binary +++ b/test/installation/node/install from binary @@ -4,6 +4,8 @@ die () { echo $@ ; exit 1; } . ../../../nvm.sh +nvm unalias default || die 'unable to unalias default' + NVM_TEST_VERSION=v0.10.7 # Remove the stuff we're clobbering. @@ -16,3 +18,6 @@ nvm install $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed" [ -d ../../../$NVM_TEST_VERSION ] nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" +# ensure default is set +NVM_CURRENT_DEFAULT="$(nvm_alias default)" +[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)" diff --git a/test/installation/node/install from source b/test/installation/node/install from source index 3cf0389..150aa87 100755 --- a/test/installation/node/install from source +++ b/test/installation/node/install from source @@ -4,6 +4,8 @@ die () { echo $@ ; exit 1; } . ../../../nvm.sh +nvm unalias default || die 'unable to unalias default' + NVM_TEST_VERSION=v0.10.7 # Remove the stuff we're clobbering. @@ -16,3 +18,6 @@ nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' fail [ -d ../../../$NVM_TEST_VERSION ] nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" +# ensure default is set +NVM_CURRENT_DEFAULT="$(nvm_alias default)" +[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)" diff --git a/test/sourcing/setup b/test/sourcing/setup index 4d5a97b..201b9c1 100755 --- a/test/sourcing/setup +++ b/test/sourcing/setup @@ -1,6 +1,7 @@ #!/bin/sh mkdir -p ../../alias +rm -rf ../../alias/default rm -f ../../.nvmrc rm -rf ../../v0.10.7 rm -rf ../../v0.9.7 @@ -8,5 +9,6 @@ rm -rf ../../v0.9.12 . ../../nvm.sh nvm install 0.10.1 || echo >&2 'nvm install 0.10.1 failed' +nvm unalias default || 'removing default alias failed' nvm unload || echo >&2 'nvm unload failed'