make install use a different nvm_version to make not specifying the v avoid clobbering aliases

master
Nathan LaFreniere 2012-10-04 10:32:36 -07:00
parent e755c47d5a
commit 693abf3173
1 changed files with 28 additions and 17 deletions

45
nvm.sh
View File

@ -23,10 +23,6 @@ nvm_version()
# The default version is the current one
if [ ! "$PATTERN" ]; then
PATTERN='current'
elif [ "${PATTERN:0:1}" != "v" ]; then
if [ "$PATTERN" != "default" -a "$PATTERN" != "current" ]; then
PATTERN=v$PATTERN
fi
fi
VERSION=`nvm_ls $PATTERN | tail -n1`
@ -37,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
@ -64,6 +71,21 @@ nvm_ls()
return
}
nvm_ls_remote()
{
PATTERN=$1
VERSIONS=`curl -s http://nodejs.org/dist/ \
| egrep -o '[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=''
@ -77,17 +99,6 @@ print_versions()
echo -e "$OUTPUT" | column
}
nvm_ls_remote()
{
PATTERN=$1
curl -s http://nodejs.org/dist/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| sort -u -k 1,1n -k 2,2n -k 3,3n -t . \
| tr "\n" "\t"
echo ""
}
nvm()
{
if [ $# -lt 1 ]; then
@ -130,7 +141,7 @@ nvm()
nvm help
return
fi
VERSION=`nvm_version $2`
VERSION=`nvm_remote_version $2`
ADDITIONAL_PARAMETERS=''
shift
shift
@ -275,7 +286,7 @@ nvm()
return
;;
"ls-remote" | "list-remote" )
nvm_ls_remote
print_versions "`nvm_ls_remote $2`"
return
;;
"alias" )