use a subshell instead of setting the START var

also don't try to install npm if node installation fails.
master
Scott Bronson 2011-02-13 21:06:13 -08:00 committed by Tim Caswell
parent 8e0406e95b
commit d13d6b199a
1 changed files with 18 additions and 14 deletions

32
nvm.sh
View File

@ -36,21 +36,25 @@ nvm()
nvm help nvm help
return; return;
fi fi
START=`pwd` if (
mkdir -p "$NVM_DIR/src" && \ mkdir -p "$NVM_DIR/src" &&
cd "$NVM_DIR/src" && \ cd "$NVM_DIR/src" && \
wget "http://nodejs.org/dist/node-$2.tar.gz" -N && \ wget "http://nodejs.org/dist/node-$2.tar.gz" -N && \
tar -xzf "node-$2.tar.gz" && \ tar -xzf "node-$2.tar.gz" && \
cd "node-$2" && \ cd "node-$2" && \
./configure --prefix="$NVM_DIR/$2" && \ ./configure --prefix="$NVM_DIR/$2" && \
make && \ make && \
make install && \ make install
nvm use $2 )
if ! which npm ; then then
echo "Installing npm..." nvm use $2
curl http://npmjs.org/install.sh | sh if ! which npm ; then
echo "Installing npm..."
curl http://npmjs.org/install.sh | sh
fi
else
echo "nvm: install $2 failed!"
fi fi
cd $START
;; ;;
"deactivate" ) "deactivate" )
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then if [[ $PATH == *$NVM_DIR/*/bin* ]]; then