Change version() to nvm_version()

It's a bit less conflict-y
master
Isaac Wolkerstorfer 2011-01-22 20:54:15 +01:00
parent a7328b3711
commit 590b283e65
1 changed files with 14 additions and 14 deletions

28
nvm.sh
View File

@ -9,12 +9,12 @@
export NVM_DIR=$(dirname ${BASH_ARGV[0]}) export NVM_DIR=$(dirname ${BASH_ARGV[0]})
# Expand a version using the version cache # Expand a version using the version cache
version() nvm_version()
{ {
PATTERN=$1 PATTERN=$1
VERSION='' VERSION=''
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
version `cat $NVM_DIR/alias/$PATTERN` nvm_version `cat $NVM_DIR/alias/$PATTERN`
return return
fi fi
# If it looks like an explicit version, don't do anything funny # If it looks like an explicit version, don't do anything funny
@ -83,7 +83,7 @@ nvm()
nvm help nvm help
return; return;
fi fi
VERSION=`version $2` VERSION=`nvm_version $2`
START=`pwd` START=`pwd`
mkdir -p "$NVM_DIR/src" && \ mkdir -p "$NVM_DIR/src" && \
rm -f "$NVM_DIR/$2" && \ rm -f "$NVM_DIR/$2" && \
@ -120,7 +120,7 @@ nvm()
nvm help nvm help
return return
fi fi
VERSION=`version $2` VERSION=`nvm_version $2`
if [ ! -d $NVM_DIR/$VERSION ]; then if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed yet" echo "$VERSION version is not installed yet"
return; return;
@ -143,12 +143,12 @@ nvm()
;; ;;
"ls" ) "ls" )
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
version $2 nvm_version $2
return return
fi fi
version all nvm_version all
for P in {stable,latest,current}; do for P in {stable,latest,current}; do
echo -ne "$P: \t"; version $P echo -ne "$P: \t"; nvm_version $P
done done
nvm alias nvm alias
echo "# use 'nvm sync' to update from nodejs.org" echo "# use 'nvm sync' to update from nodejs.org"
@ -157,7 +157,7 @@ nvm()
if [ $# -le 2 ]; then if [ $# -le 2 ]; then
(cd $NVM_DIR/alias; for ALIAS in `ls $2* 2>/dev/null`; do (cd $NVM_DIR/alias; for ALIAS in `ls $2* 2>/dev/null`; do
DEST=`cat $ALIAS` DEST=`cat $ALIAS`
VERSION=`version $DEST` VERSION=`nvm_version $DEST`
if [ "$DEST" = "$VERSION" ]; then if [ "$DEST" = "$VERSION" ]; then
echo "$ALIAS -> $DEST" echo "$ALIAS -> $DEST"
else else
@ -172,7 +172,7 @@ nvm()
return return
fi fi
mkdir -p $NVM_DIR/alias mkdir -p $NVM_DIR/alias
VERSION=`version $3` VERSION=`nvm_version $3`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "! WARNING: Version '$3' does not exist." >&2 echo "! WARNING: Version '$3' does not exist." >&2
fi fi
@ -185,8 +185,8 @@ nvm()
fi fi
;; ;;
"sync" ) "sync" )
LATEST=`version latest` LATEST=`nvm_version latest`
STABLE=`version stable` STABLE=`nvm_version stable`
(cd $NVM_DIR (cd $NVM_DIR
rm -f v* 2>/dev/null rm -f v* 2>/dev/null
echo -n "# syncing with nodejs.org..." echo -n "# syncing with nodejs.org..."
@ -195,15 +195,15 @@ nvm()
done done
echo " done." echo " done."
) )
[ "$STABLE" = `version stable` ] || echo "NEW stable: `version stable`" [ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`"
[ "$LATEST" = `version latest` ] || echo "NEW latest: `version latest`" [ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`"
;; ;;
"clear-cache" ) "clear-cache" )
rm -f $NVM_DIR/v* rm -f $NVM_DIR/v*
echo "Cache cleared." echo "Cache cleared."
;; ;;
"version" ) "version" )
version $2 nvm_version $2
;; ;;
* ) * )
nvm help nvm help