From d13d6b199a615851c53777095305f3fe7fdf5369 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Sun, 13 Feb 2011 21:06:13 -0800 Subject: [PATCH 1/3] use a subshell instead of setting the START var also don't try to install npm if node installation fails. --- nvm.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/nvm.sh b/nvm.sh index 99eb87a..c2a1726 100644 --- a/nvm.sh +++ b/nvm.sh @@ -36,21 +36,25 @@ nvm() nvm help return; fi - START=`pwd` - mkdir -p "$NVM_DIR/src" && \ - cd "$NVM_DIR/src" && \ - wget "http://nodejs.org/dist/node-$2.tar.gz" -N && \ - tar -xzf "node-$2.tar.gz" && \ - cd "node-$2" && \ - ./configure --prefix="$NVM_DIR/$2" && \ - make && \ - make install && \ - nvm use $2 - if ! which npm ; then - echo "Installing npm..." - curl http://npmjs.org/install.sh | sh + if ( + mkdir -p "$NVM_DIR/src" && + cd "$NVM_DIR/src" && \ + wget "http://nodejs.org/dist/node-$2.tar.gz" -N && \ + tar -xzf "node-$2.tar.gz" && \ + cd "node-$2" && \ + ./configure --prefix="$NVM_DIR/$2" && \ + make && \ + make install + ) + then + nvm use $2 + if ! which npm ; then + echo "Installing npm..." + curl http://npmjs.org/install.sh | sh + fi + else + echo "nvm: install $2 failed!" fi - cd $START ;; "deactivate" ) if [[ $PATH == *$NVM_DIR/*/bin* ]]; then From f668d354a931cdaf7f7d38ca33f9da4249830dbf Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Fri, 18 Feb 2011 09:46:47 -0800 Subject: [PATCH 2/3] Update the sample text to reflect current stable --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index c2a1726..2053719 100644 --- a/nvm.sh +++ b/nvm.sh @@ -27,8 +27,8 @@ nvm() echo " nvm deactivate Undo effects of NVM on current shell" echo echo "Example:" - echo " nvm install v0.2.5" - echo " nvm use v0.2.5" + echo " nvm install v0.4.0" + echo " nvm use v0.4.0" echo ;; "install" ) From 66a9f01a0e9b0b4224e13a787bd843b57e79a75e Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Fri, 25 Feb 2011 09:17:27 -0800 Subject: [PATCH 3/3] Fix for ZSH by wavded --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 2053719..a594381 100644 --- a/nvm.sh +++ b/nvm.sh @@ -6,7 +6,7 @@ # with much bash help from Matthew Ranney # Auto detect the NVM_DIR using magic bash 3.x stuff -export NVM_DIR=$(dirname ${BASH_ARGV[0]}) +export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd) nvm() {