From 4cdf356cdc714e13045d795ad2e3530ef5ca0ecf Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 29 Sep 2014 00:10:06 -0700 Subject: [PATCH] Support `nvm ls-remote stable` and `nvm ls-remote unstable` --- nvm.sh | 6 ++++-- test/fast/Unit tests/nvm_ls_remote | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 85c850e..69de1be 100644 --- a/nvm.sh +++ b/nvm.sh @@ -317,7 +317,9 @@ nvm_ls_remote() { local VERSIONS local GREP_OPTIONS GREP_OPTIONS='' - if [ -n "$PATTERN" ]; then + if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then + PATTERN="$(nvm_remote_version "$(nvm_print_implicit_alias remote "$PATTERN")")" + elif [ -n "$PATTERN" ]; then PATTERN="$(nvm_ensure_version_prefix "$PATTERN")" else PATTERN=".*" @@ -518,7 +520,7 @@ nvm() { nobinary=1 fi - provided_version=$1 + provided_version="$1" if [ -z "$provided_version" ]; then if [ $version_not_provided -ne 1 ]; then diff --git a/test/fast/Unit tests/nvm_ls_remote b/test/fast/Unit tests/nvm_ls_remote index c6f2e7c..8b7da02 100755 --- a/test/fast/Unit tests/nvm_ls_remote +++ b/test/fast/Unit tests/nvm_ls_remote @@ -464,5 +464,22 @@ v0.3.8" [ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT" +# Sanity checks +OUTPUT="$(nvm_print_implicit_alias remote stable)" +EXPECTED_OUTPUT="0.10" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT" + +OUTPUT="$(nvm_print_implicit_alias remote unstable)" +EXPECTED_OUTPUT="0.11" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT" + +OUTPUT="$(nvm_ls_remote stable)" +EXPECTED_OUTPUT="v0.10.32" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT" + +OUTPUT="$(nvm_ls_remote unstable)" +EXPECTED_OUTPUT="v0.11.14" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT" + cleanup