Support `nvm ls-remote stable` and `nvm ls-remote unstable`

master
Jordan Harband 2014-09-29 00:10:06 -07:00
parent c918e570b6
commit 4cdf356cdc
2 changed files with 21 additions and 2 deletions

6
nvm.sh
View File

@ -317,7 +317,9 @@ nvm_ls_remote() {
local VERSIONS local VERSIONS
local GREP_OPTIONS local GREP_OPTIONS
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")" PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
else else
PATTERN=".*" PATTERN=".*"
@ -518,7 +520,7 @@ nvm() {
nobinary=1 nobinary=1
fi fi
provided_version=$1 provided_version="$1"
if [ -z "$provided_version" ]; then if [ -z "$provided_version" ]; then
if [ $version_not_provided -ne 1 ]; then if [ $version_not_provided -ne 1 ]; then

View File

@ -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" [ "_$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 cleanup