Ensure that `nvm use` works when .nvmrc contains "system"

master
Jordan Harband 2014-09-28 16:43:40 -07:00
parent d5fe657382
commit 804f2759f8
1 changed files with 13 additions and 13 deletions

22
nvm.sh
View File

@ -666,8 +666,17 @@ nvm() {
if [ -n "$NVM_RC_VERSION" ]; then if [ -n "$NVM_RC_VERSION" ]; then
VERSION=`nvm_version $NVM_RC_VERSION` VERSION=`nvm_version $NVM_RC_VERSION`
fi fi
elif [ "_$2" != '_system' ]; then
VERSION="$(nvm_version "$2")"
else else
if [ $2 = 'system' ]; then VERSION="$2"
fi
if [ -z "$VERSION" ]; then
nvm help
return 127
fi
if [ "_$VERSION" = '_system' ]; then
if nvm_has_system_node && nvm deactivate >/dev/null; then if nvm_has_system_node && nvm deactivate >/dev/null; then
echo "Now using system version of node: $(node -v 2>/dev/null)." echo "Now using system version of node: $(node -v 2>/dev/null)."
return return
@ -675,17 +684,8 @@ nvm() {
echo "System version of node not found." >&2 echo "System version of node not found." >&2
return 127 return 127
fi fi
else
VERSION=`nvm_version $2`
fi
fi
if [ -z "$VERSION" ]; then
nvm help
return 127
fi
if [ -z "$VERSION" ]; then
VERSION=`nvm_version $2`
fi fi
local NVM_VERSION_DIR local NVM_VERSION_DIR
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")" NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
if [ ! -d "$NVM_VERSION_DIR" ]; then if [ ! -d "$NVM_VERSION_DIR" ]; then