mirror of
https://github.com/tj/n.git
synced 2024-11-28 21:22:03 +01:00
Added n --latest
This commit is contained in:
parent
d5622a5499
commit
a92ff56ebb
15
bin/n
15
bin/n
@ -53,10 +53,11 @@ display_help() {
|
||||
Commands:
|
||||
|
||||
n Output versions installed
|
||||
n <version> [config ...] Install and/or use node <version>
|
||||
n use <version> [args ...] Execute node <version> with [args ...]
|
||||
n bin <version> Output bin path for <version>
|
||||
n rm <version ...> Remove the given version(s)
|
||||
n <version> [config ...] Install and/or use node <version>
|
||||
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 ;;
|
||||
|
Loading…
Reference in New Issue
Block a user