From d1a90ca15c726a5f748860648477816e335d243f Mon Sep 17 00:00:00 2001 From: Daniel Bretoi Date: Fri, 19 Dec 2014 10:41:53 -0800 Subject: [PATCH 1/3] work like system which. show system node without changing to use it --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index bd81595..721a889 100644 --- a/nvm.sh +++ b/nvm.sh @@ -965,7 +965,7 @@ nvm() { if [ "_$VERSION" = '_system' ]; then if nvm_has_system_node >/dev/null 2>&1; then - echo $(nvm use system && echo dirname $(which node)) + echo $(nvm deactivate > /dev/null 2>&1 && echo $(which node)) return else echo "System version of node not found." >&2 @@ -982,7 +982,7 @@ nvm() { echo "$VERSION version is not installed yet" >&2 return 1 fi - echo $NVM_DIR/$VERSION/bin + echo $NVM_DIR/$VERSION/bin/node ;; "alias" ) mkdir -p "$NVM_DIR/alias" From f196ace5ddffd7e7ef59f65864449ee87de6611a Mon Sep 17 00:00:00 2001 From: Daniel Bretoi Date: Fri, 19 Dec 2014 11:05:51 -0800 Subject: [PATCH 2/3] style --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 721a889..94b40f5 100644 --- a/nvm.sh +++ b/nvm.sh @@ -965,7 +965,7 @@ nvm() { if [ "_$VERSION" = '_system' ]; then if nvm_has_system_node >/dev/null 2>&1; then - echo $(nvm deactivate > /dev/null 2>&1 && echo $(which node)) + echo $(nvm use system > /dev/null 2>&1 && echo $(which node)) return else echo "System version of node not found." >&2 @@ -982,7 +982,7 @@ nvm() { echo "$VERSION version is not installed yet" >&2 return 1 fi - echo $NVM_DIR/$VERSION/bin/node + echo $(nvm use "$VERSION" >/dev/null 2>&1 && which node) ;; "alias" ) mkdir -p "$NVM_DIR/alias" From 99ca0de18f970065926f072458940b37c0a7e419 Mon Sep 17 00:00:00 2001 From: Daniel Bretoi Date: Fri, 19 Dec 2014 11:31:46 -0800 Subject: [PATCH 3/3] revert echoing path. make tests even better --- nvm.sh | 2 +- ...g \"nvm which 0.0.2\" should display only version 0.0.2." | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index 94b40f5..d5bd9e6 100644 --- a/nvm.sh +++ b/nvm.sh @@ -982,7 +982,7 @@ nvm() { echo "$VERSION version is not installed yet" >&2 return 1 fi - echo $(nvm use "$VERSION" >/dev/null 2>&1 && which node) + echo $NVM_DIR/$VERSION/bin/node ;; "alias" ) mkdir -p "$NVM_DIR/alias" diff --git "a/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." "b/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." index 53ddf30..a39a456 100755 --- "a/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." +++ "b/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." @@ -9,12 +9,13 @@ die () { echo $@ ; exit 1; } # The result should contain only the appropriate version numbers. -nvm which 0.0.2 | grep "$NVM_DIR/v0.0.2/bin" > /dev/null +nvm which 0.0.2 +nvm which 0.0.2 | grep "$NVM_DIR/v0.0.2/bin/node" > /dev/null if [ $? -ne 0 ]; then die '"nvm which 0.0.2" did not contain the correct path' fi -nvm which 0.0.20 | grep "$NVM_DIR/v0.0.20/bin" > /dev/null +nvm which 0.0.20 | grep "$NVM_DIR/v0.0.20/bin/node" > /dev/null if [ $? -ne 0 ]; then die '"nvm which 0.0.2" did not contain the correct path' fi