From a92ff56ebb6161cb8f4dd47f62d2c893b93d6b28 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Fri, 21 Jan 2011 15:22:46 -0800 Subject: [PATCH] Added `n --latest` --- bin/n | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/n b/bin/n index 0481030..1a08005 100755 --- a/bin/n +++ b/bin/n @@ -53,10 +53,11 @@ display_help() { Commands: n Output versions installed + n [config ...] Install and/or use node n use [args ...] Execute node with [args ...] n bin Output bin path for n rm Remove the given version(s) - n [config ...] Install and/or use node + n --latest Output the latest node version available Options: @@ -209,6 +210,17 @@ execute_with_version() { fi } +# +# Display the latest node release version. +# + +display_latest_version() { + $GET 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 +} + # Handle arguments if test $# -eq 0; then @@ -218,6 +230,7 @@ else case $1 in -V|--version) display_n_version ;; -h|--help|help) display_help ;; + --latest) display_latest_version $2; exit ;; bin|which) display_bin_path_for_version $2; exit ;; as|use) execute_with_version ${@:2}; exit ;; rm|-) remove_version ${@:2}; exit ;;