From b890a96024d9e1f208a329397f63374b59cbfaa7 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 7 Feb 2011 15:51:32 -0800 Subject: [PATCH] Added `n ls|list` to show versions available --- bin/n | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/n b/bin/n index 6b398dc..ebc57f7 100755 --- a/bin/n +++ b/bin/n @@ -241,6 +241,17 @@ display_latest_version() { | tail -n1 } +# +# Display the versions of node available. +# + +list_versions() { + $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 . \ + | awk '{ print " " $1 }' +} + # Handle arguments if test $# -eq 0; then @@ -255,6 +266,7 @@ else as|use) execute_with_version ${@:2}; exit ;; rm|-) remove_version ${@:2}; exit ;; latest) install_node `n --latest`; exit ;; + ls|list) list_versions ${@:2}; exit ;; *) install_node $@; exit ;; esac shift