Added command nvm install stable

nvm auto-detects last stable relase and fetch it.
This commit is contained in:
Michał Koźmiński 2013-08-28 11:35:14 +02:00
parent e6d1d0c4de
commit b8ca75d15c
1 changed files with 18 additions and 3 deletions

21
nvm.sh
View File

@ -54,7 +54,11 @@ nvm_version() {
nvm_remote_version() { nvm_remote_version() {
local PATTERN=$1 local PATTERN=$1
VERSION=`nvm_ls_remote $PATTERN | tail -n1` if [[ $PATTERN == "stable" ]]; then
VERSION=`nvm_last_stable_version`
else
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
fi
echo "$VERSION" echo "$VERSION"
if [ "$VERSION" = 'N/A' ]; then if [ "$VERSION" = 'N/A' ]; then
@ -111,6 +115,17 @@ nvm_ls_remote() {
return return
} }
nvm_last_stable_version(){
local VERSION
VERSION=`curl http://nodejs.org/dist/latest/ | grep -o 'node-v.*\"' -m 1 | grep -o 'v[0-9]*\.[0-9]*\.[0-9]*'`
if [ ! "$VERSION" ]; then
echo "N/A"
return
fi
echo "$VERSION"
return
}
nvm_checksum() { nvm_checksum() {
if [ "$1" = "$2" ]; then if [ "$1" = "$2" ]; then
return return
@ -223,7 +238,7 @@ nvm() {
fi fi
if [ "$os" = "freebsd" ]; then if [ "$os" = "freebsd" ]; then
nobinary=1 nobinary=1
fi fi
VERSION=`nvm_remote_version $1` VERSION=`nvm_remote_version $1`
@ -281,7 +296,7 @@ nvm() {
sum='' sum=''
make='make' make='make'
if [ "$os" = "freebsd" ]; then if [ "$os" = "freebsd" ]; then
make='gmake' make='gmake'
fi fi
local tmpdir="$NVM_DIR/src" local tmpdir="$NVM_DIR/src"
local tmptarball="$tmpdir/node-$VERSION.tar.gz" local tmptarball="$tmpdir/node-$VERSION.tar.gz"