creationix 2010-04-15 09:20:27 -07:00
parent 4f4dec1c89
commit d5b8294497
1 changed files with 49 additions and 49 deletions

98
nvm.sh
View File

@ -9,53 +9,53 @@ NVM_DIR=$HOME/.nvm
nvm()
{
START=`pwd`
if [ $# -lt 1 ]; then
nvm help
return
fi
case $1 in
"help" )
echo
echo "Node Version Manager"
echo "Usage:"
echo " nvm install version"
echo " nvm use version"
echo " nvm list"
echo
;;
"install" )
if [ $# -lt 2 ]; then
nvm help
return;
fi
echo $START
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
cd $START
;;
"use" )
if [ $# -lt 2 ]; then
nvm help
return;
fi
# TODO: Remove old nvm paths before adding this one
PATH="$NVM_DIR/$2/bin:$PATH"
echo "Now using node $2"
;;
"list" )
# TODO: put a star by the current active one if possible
ls "$NVM_DIR" | grep -v src
;;
* )
nvm help
;;
esac
START=`pwd`
if [ $# -lt 1 ]; then
nvm help
return
fi
case $1 in
"help" )
echo
echo "Node Version Manager"
echo "Usage:"
echo " nvm install version"
echo " nvm use version"
echo " nvm list"
echo
;;
"install" )
if [ $# -lt 2 ]; then
nvm help
return;
fi
echo $START
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
cd $START
;;
"use" )
if [ $# -lt 2 ]; then
nvm help
return;
fi
# TODO: Remove old nvm paths before adding this one
PATH="$NVM_DIR/$2/bin:$PATH"
echo "Now using node $2"
;;
"list" )
# TODO: put a star by the current active one if possible
ls "$NVM_DIR" | grep -v src
;;
* )
nvm help
;;
esac
}