From 985f9e8aeab26b73c12cf5adfdaebb66c6668931 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 9 Jan 2013 17:31:54 +0800 Subject: [PATCH 1/2] add two method: show stable or latest version. Signed-off-by: Bo-Yi Wu --- nvm.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/nvm.sh b/nvm.sh index 303925b..7e5af9e 100755 --- a/nvm.sh +++ b/nvm.sh @@ -104,6 +104,27 @@ nvm_checksum() fi } +# +# Display the latest node release version. +# + +display_latest_version() { + curl -# -L 2> /dev/null http://nodejs.org/dist/ \ + | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \ + | sort -u -k 1,1n -k 2,2n -k 3,3n -t . \ + | tail -n1 +} + +# +# Display the latest stable node release version. +# + +display_latest_stable_version() { + curl -# -L 2> /dev/null http://nodejs.org/dist/ \ + | egrep -o '[0-9]+\.\d*[02468]\.[0-9]+' \ + | sort -u -k 1,1n -k 2,2n -k 3,3n -t . \ + | tail -n1 +} print_versions() { @@ -163,6 +184,8 @@ nvm() echo " nvm alias Set an alias named pointing to " echo " nvm unalias Deletes the alias named " echo " nvm copy-packages Install global NPM packages contained in to current version" + echo " nvm latest Show latest version" + echo " nvm stable Show stable version" echo echo "Example:" echo " nvm install v0.4.12 Install a specific version number" @@ -437,6 +460,12 @@ nvm() "version" ) print_versions "`nvm_version $2`" ;; + "latest" ) + display_latest_version + ;; + "stable" ) + display_latest_stable_version + ;; * ) nvm help ;; From b4ecd2f563980b321a6f69231297a6eefd551c9c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 9 Jan 2013 18:07:44 +0800 Subject: [PATCH 2/2] Add stable and latest for install,uninstall command Signed-off-by: Bo-Yi Wu --- nvm.sh | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/nvm.sh b/nvm.sh index 7e5af9e..e9f7434 100755 --- a/nvm.sh +++ b/nvm.sh @@ -171,21 +171,21 @@ nvm() echo "Node Version Manager" echo echo "Usage:" - echo " nvm help Show this message" - echo " nvm install Download and install a " - echo " nvm uninstall Uninstall a version" - echo " nvm use Modify PATH to use " - echo " nvm run [] Run with as arguments" - echo " nvm ls List installed versions" - echo " nvm ls 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 [] Show all aliases beginning with " - echo " nvm alias Set an alias named pointing to " - echo " nvm unalias Deletes the alias named " - echo " nvm copy-packages Install global NPM packages contained in to current version" - echo " nvm latest Show latest version" - echo " nvm stable Show stable version" + echo " nvm help Show this message" + echo " nvm install Download and install a " + echo " nvm uninstall Uninstall a version" + echo " nvm use Modify PATH to use " + echo " nvm run [] Run with as arguments" + echo " nvm ls List installed versions" + echo " nvm ls 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 [] Show all aliases beginning with " + echo " nvm alias Set an alias named pointing to " + echo " nvm unalias Deletes the alias named " + echo " nvm copy-packages Install global NPM packages contained in to current version" + echo " nvm latest Show latest version" + echo " nvm stable Show stable version" echo echo "Example:" echo " nvm install v0.4.12 Install a specific version number" @@ -216,7 +216,18 @@ nvm() nvm help return 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='' shift shift @@ -309,7 +320,18 @@ nvm() echo "nvm: Cannot uninstall currently-active node version, $2." return 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 echo "$VERSION version is not installed yet... installing" nvm install $VERSION