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