From ca89cceb99e7eb2b51cf4ad967068e8e8102f97b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 14 Oct 2014 17:38:42 -0700 Subject: [PATCH] Default $NVM_SYMLINK_CURRENT to off (create a "current" symlink on `use`). Fixes #499. --- README.markdown | 2 +- nvm.sh | 2 +- ...uld create and change the \"current\" symlink" | 1 + ...nt\" symlink if $NVM_SYMLINK_CURRENT is false" | 15 ++++++++------- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.markdown b/README.markdown index 3adb690..63030d7 100644 --- a/README.markdown +++ b/README.markdown @@ -95,7 +95,7 @@ To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`: NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10 -`nvm use` will, by defaut, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to any value other than "true" to disable this behavior. +`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs. ## License diff --git a/nvm.sh b/nvm.sh index 7d53ea7..6c7a66c 100644 --- a/nvm.sh +++ b/nvm.sh @@ -802,7 +802,7 @@ nvm() { export NODE_PATH export NVM_PATH="$NVM_VERSION_DIR/lib/node" export NVM_BIN="$NVM_VERSION_DIR/bin" - if [ "$NVM_SYMLINK_CURRENT" = true ] || [ -z "$NVM_SYMLINK_CURRENT" ]; then + if [ "$NVM_SYMLINK_CURRENT" = true ]; then rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current" fi echo "Now using node $VERSION" diff --git "a/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" "b/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" index 781eb94..d5fda3c 100755 --- "a/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" +++ "b/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" @@ -1,5 +1,6 @@ #!/bin/bash +export NVM_SYMLINK_CURRENT=true . ../../nvm.sh rm -rf ../../v0.10.29 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 23bbe38..4ac8b4b 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" @@ -45,39 +45,40 @@ function isCurrentSymlinkPresent() { NVM_SYMLINK_CURRENT=false cleanup runNvmUse -isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!" +isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!" registerExpectedNoSymlink $? NVM_SYMLINK_CURRENT=true cleanup runNvmUse -isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!" +isCurrentSymlinkPresent || echo >&2 "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!" registerExpectedSymlink $? NVM_SYMLINK_CURRENT=garbagevalue cleanup runNvmUse -isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!" +isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!" registerExpectedNoSymlink $? NVM_SYMLINK_CURRENT=0 cleanup runNvmUse -isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!" +isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!" registerExpectedNoSymlink $? NVM_SYMLINK_CURRENT=1 cleanup runNvmUse -isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!" +isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!" registerExpectedNoSymlink $? unset NVM_SYMLINK_CURRENT cleanup runNvmUse -isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!" -registerExpectedSymlink $? +isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!" +registerExpectedNoSymlink $? cleanup [ ${TEST_FAILED} -ne 0 ] && echo "${TEST_COUNT} tested, ${TEST_PASSED} passed, ${TEST_FAILED} failed" && exit 1 || true +