From 8746d63041e48cac250aed752ef0bfb9a95fd1ba Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 22 Aug 2015 09:45:49 -0700 Subject: [PATCH] Ensure after node v4.0 is released, `stable` will simply refer to the latest node. --- nvm.sh | 14 +++++--- .../nvm_print_implicit_alias success | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/nvm.sh b/nvm.sh index dc6ade4..a247d93 100755 --- a/nvm.sh +++ b/nvm.sh @@ -852,6 +852,7 @@ nvm_print_implicit_alias() { local STABLE local UNSTABLE local MOD + local NORMALIZED_VERSION ZHS_HAS_SHWORDSPLIT_UNSET=1 if nvm_has "setopt"; then @@ -859,11 +860,16 @@ nvm_print_implicit_alias() { setopt shwordsplit fi for MINOR in $LAST_TWO; do - MOD=$(expr "$(nvm_normalize_version "$MINOR")" \/ 1000000 \% 2) - if [ $MOD -eq 0 ]; then + NORMALIZED_VERSION="$(nvm_normalize_version "$MINOR")" + if [ "_0${NORMALIZED_VERSION#?}" != "_$NORMALIZED_VERSION" ]; then STABLE="$MINOR" - elif [ $MOD -eq 1 ]; then - UNSTABLE="$MINOR" + else + MOD=$(expr "$NORMALIZED_VERSION" \/ 1000000 \% 2) + if [ $MOD -eq 0 ]; then + STABLE="$MINOR" + elif [ $MOD -eq 1 ]; then + UNSTABLE="$MINOR" + fi fi done if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then diff --git a/test/fast/Unit tests/nvm_print_implicit_alias success b/test/fast/Unit tests/nvm_print_implicit_alias success index 1439844..425350f 100755 --- a/test/fast/Unit tests/nvm_print_implicit_alias success +++ b/test/fast/Unit tests/nvm_print_implicit_alias success @@ -8,6 +8,8 @@ cleanup() { rm -rf ../../../v0.5.7 rm -rf ../../../v0.7.7 rm -rf ../../../versions/io.js/v0.98.0 + rm -rf ../../../versions/node/v1.0.0 + rm -rf ../../../versions/node/v1.1.0 unset -f nvm_ls_remote nvm_ls_remote_iojs } @@ -32,6 +34,17 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)" LATEST_IOJS="$(nvm_print_implicit_alias local iojs)" [ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS" +## node post v1.0/io.js merger ## +mkdir -p ../../../versions/node/v1.0.0 +mkdir -p ../../../versions/node/v1.1.0 + +LATEST_STABLE="$(nvm_print_implicit_alias local stable)" +[ "_$LATEST_STABLE" = "_1.1" ] || die "local stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE" + +LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)" +[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest pre-v1.0 odd minor: expected 0.7, got $LATEST_UNSTABLE" +## ** ## + nvm_ls_remote() { echo "v0.4.3" echo "v0.5.4" @@ -65,5 +78,28 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)" LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)" [ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS" +## node post v1.0/io.js merger ## +nvm_ls_remote() { + echo "v0.4.3" + echo "v0.5.4" + echo "v0.6.6" + echo "v0.7.7" + echo "v0.9.7" + echo "v0.4.3" + echo "v0.5.4" + echo "v0.6.6" + echo "v0.7.7" + echo "v0.9.7" + echo "v1.0.0" + echo "v1.1.0" +} + +LATEST_STABLE="$(nvm_print_implicit_alias remote stable)" +[ "_$LATEST_STABLE" = "_1.1" ] || die "remote stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE" + +LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)" +[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd pre-v1.0 minor: expected 0.9, got $LATEST_UNSTABLE" +## ** ## + cleanup