commit
80cf1159bb
|
@ -21,16 +21,16 @@ Often I also put in a line to use a specific version of node.
|
|||
|
||||
To download, compile, and install the v0.6.14 release of node, do this:
|
||||
|
||||
nvm install v0.6.14
|
||||
nvm install 0.6.14
|
||||
|
||||
|
||||
And then in any new shell just use the installed version:
|
||||
|
||||
nvm use v0.6.14
|
||||
nvm use 0.6.14
|
||||
|
||||
Or you can just run it:
|
||||
|
||||
nvm run v0.6.14
|
||||
nvm run 0.6.14
|
||||
|
||||
If you want to see what versions are available:
|
||||
|
||||
|
|
36
nvm.sh
36
nvm.sh
|
@ -33,6 +33,17 @@ nvm_version()
|
|||
fi
|
||||
}
|
||||
|
||||
nvm_remote_version()
|
||||
{
|
||||
PATTERN=$1
|
||||
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
||||
echo "v$VERSION"
|
||||
|
||||
if [ "$VERSION" = 'N/A' ]; then
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_ls()
|
||||
{
|
||||
PATTERN=$1
|
||||
|
@ -60,6 +71,21 @@ nvm_ls()
|
|||
return
|
||||
}
|
||||
|
||||
nvm_ls_remote()
|
||||
{
|
||||
PATTERN=$1
|
||||
VERSIONS=`curl -s http://nodejs.org/dist/ \
|
||||
| egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||
| grep -w "${PATTERN}" \
|
||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||
if [ ! "$VERSIONS" ]; then
|
||||
echo "N/A"
|
||||
return
|
||||
fi
|
||||
echo "$VERSIONS"
|
||||
return
|
||||
}
|
||||
|
||||
print_versions()
|
||||
{
|
||||
OUTPUT=''
|
||||
|
@ -92,6 +118,7 @@ nvm()
|
|||
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
|
||||
echo " nvm ls List installed versions"
|
||||
echo " nvm ls <version> List versions matching a given description"
|
||||
echo " nvm ls-remote List remote versions available for install"
|
||||
echo " nvm deactivate Undo effects of NVM on current shell"
|
||||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||
|
@ -114,7 +141,7 @@ nvm()
|
|||
nvm help
|
||||
return
|
||||
fi
|
||||
VERSION=`nvm_version $2`
|
||||
VERSION=`nvm_remote_version $2`
|
||||
ADDITIONAL_PARAMETERS=''
|
||||
shift
|
||||
shift
|
||||
|
@ -174,7 +201,8 @@ nvm()
|
|||
fi
|
||||
VERSION=`nvm_version $2`
|
||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
||||
echo "$VERSION version is not installed yet"
|
||||
echo "$VERSION version is not installed yet... installing"
|
||||
nvm install $VERSION
|
||||
return;
|
||||
fi
|
||||
|
||||
|
@ -257,6 +285,10 @@ nvm()
|
|||
fi
|
||||
return
|
||||
;;
|
||||
"ls-remote" | "list-remote" )
|
||||
print_versions "`nvm_ls_remote $2`"
|
||||
return
|
||||
;;
|
||||
"alias" )
|
||||
mkdir -p $NVM_DIR/alias
|
||||
if [ $# -le 2 ]; then
|
||||
|
|
Loading…
Reference in New Issue