Add stable and latest for install,uninstall command

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2013-01-09 18:07:44 +08:00
parent 985f9e8aea
commit b4ecd2f563

30
nvm.sh
View File

@ -172,8 +172,8 @@ nvm()
echo echo
echo "Usage:" echo "Usage:"
echo " nvm help Show this message" echo " nvm help Show this message"
echo " nvm install <version> Download and install a <version>" echo " nvm install <version|stable|latest> Download and install a <version>"
echo " nvm uninstall <version> Uninstall a version" echo " nvm uninstall <version|stable|latest> Uninstall a version"
echo " nvm use <version> Modify PATH to use <version>" echo " nvm use <version> Modify PATH to use <version>"
echo " nvm run <version> [<args>] Run <version> with <args> as arguments" echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
echo " nvm ls List installed versions" echo " nvm ls List installed versions"
@ -216,7 +216,18 @@ nvm()
nvm help nvm help
return return
fi fi
VERSION=`nvm_remote_version $2` case "$2" in
"latest" )
latest_version=`display_latest_version`
VERSION=`nvm_remote_version $latest_version`
;;
"stable" )
stable_version=`display_latest_stable_version`
VERSION=`nvm_remote_version $stable_version`
;;
*) VERSION=`nvm_remote_version $2`
;;
esac
ADDITIONAL_PARAMETERS='' ADDITIONAL_PARAMETERS=''
shift shift
shift shift
@ -309,7 +320,18 @@ nvm()
echo "nvm: Cannot uninstall currently-active node version, $2." echo "nvm: Cannot uninstall currently-active node version, $2."
return return
fi fi
VERSION=`nvm_version $2` case "$2" in
"latest" )
latest_version=`display_latest_version`
VERSION=`nvm_version $latest_version`
;;
"stable" )
stable_version=`display_latest_stable_version`
VERSION=`nvm_version $stable_version`
;;
*) VERSION=`nvm_version $2`
;;
esac
if [ ! -d $NVM_DIR/$VERSION ]; then if [ ! -d $NVM_DIR/$VERSION ]; then
echo "$VERSION version is not installed yet... installing" echo "$VERSION version is not installed yet... installing"
nvm install $VERSION nvm install $VERSION