Default $NVM_SYMLINK_CURRENT to off (create a "current" symlink on `use`).

Fixes #499.
master
Jordan Harband 2014-10-14 17:38:42 -07:00
parent 7b6e06e556
commit ca89cceb99
4 changed files with 11 additions and 9 deletions

View File

@ -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

2
nvm.sh
View File

@ -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"

View File

@ -1,5 +1,6 @@
#!/bin/bash
export NVM_SYMLINK_CURRENT=true
. ../../nvm.sh
rm -rf ../../v0.10.29

View File

@ -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