From 804f2759f8318deabcf3f9be42f9205b27100dd1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 28 Sep 2014 16:43:40 -0700 Subject: [PATCH] Ensure that `nvm use` works when .nvmrc contains "system" --- nvm.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/nvm.sh b/nvm.sh index d6380cd..9722816 100644 --- a/nvm.sh +++ b/nvm.sh @@ -666,26 +666,26 @@ nvm() { if [ -n "$NVM_RC_VERSION" ]; then VERSION=`nvm_version $NVM_RC_VERSION` fi + elif [ "_$2" != '_system' ]; then + VERSION="$(nvm_version "$2")" else - if [ $2 = 'system' ]; then - if nvm_has_system_node && nvm deactivate >/dev/null; then - echo "Now using system version of node: $(node -v 2>/dev/null)." - return - else - echo "System version of node not found." >&2 - return 127 - fi - else - VERSION=`nvm_version $2` - fi + VERSION="$2" fi if [ -z "$VERSION" ]; then nvm help return 127 fi - if [ -z "$VERSION" ]; then - VERSION=`nvm_version $2` + + if [ "_$VERSION" = '_system' ]; then + if nvm_has_system_node && nvm deactivate >/dev/null; then + echo "Now using system version of node: $(node -v 2>/dev/null)." + return + else + echo "System version of node not found." >&2 + return 127 + fi fi + local NVM_VERSION_DIR NVM_VERSION_DIR="$(nvm_version_path "$VERSION")" if [ ! -d "$NVM_VERSION_DIR" ]; then