Skip to content

Commit 8746d63

Browse files
committed
Ensure after node v4.0 is released, stable will simply refer to the latest node.
1 parent b7e2d7d commit 8746d63

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

nvm.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,24 @@ nvm_print_implicit_alias() {
852852
local STABLE
853853
local UNSTABLE
854854
local MOD
855+
local NORMALIZED_VERSION
855856

856857
ZHS_HAS_SHWORDSPLIT_UNSET=1
857858
if nvm_has "setopt"; then
858859
ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
859860
setopt shwordsplit
860861
fi
861862
for MINOR in $LAST_TWO; do
862-
MOD=$(expr "$(nvm_normalize_version "$MINOR")" \/ 1000000 \% 2)
863-
if [ $MOD -eq 0 ]; then
863+
NORMALIZED_VERSION="$(nvm_normalize_version "$MINOR")"
864+
if [ "_0${NORMALIZED_VERSION#?}" != "_$NORMALIZED_VERSION" ]; then
864865
STABLE="$MINOR"
865-
elif [ $MOD -eq 1 ]; then
866-
UNSTABLE="$MINOR"
866+
else
867+
MOD=$(expr "$NORMALIZED_VERSION" \/ 1000000 \% 2)
868+
if [ $MOD -eq 0 ]; then
869+
STABLE="$MINOR"
870+
elif [ $MOD -eq 1 ]; then
871+
UNSTABLE="$MINOR"
872+
fi
867873
fi
868874
done
869875
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then

test/fast/Unit tests/nvm_print_implicit_alias success

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ cleanup() {
88
rm -rf ../../../v0.5.7
99
rm -rf ../../../v0.7.7
1010
rm -rf ../../../versions/io.js/v0.98.0
11+
rm -rf ../../../versions/node/v1.0.0
12+
rm -rf ../../../versions/node/v1.1.0
1113
unset -f nvm_ls_remote nvm_ls_remote_iojs
1214
}
1315

@@ -32,6 +34,17 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
3234
LATEST_IOJS="$(nvm_print_implicit_alias local iojs)"
3335
[ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS"
3436

37+
## node post v1.0/io.js merger ##
38+
mkdir -p ../../../versions/node/v1.0.0
39+
mkdir -p ../../../versions/node/v1.1.0
40+
41+
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
42+
[ "_$LATEST_STABLE" = "_1.1" ] || die "local stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
43+
44+
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
45+
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest pre-v1.0 odd minor: expected 0.7, got $LATEST_UNSTABLE"
46+
## ** ##
47+
3548
nvm_ls_remote() {
3649
echo "v0.4.3"
3750
echo "v0.5.4"
@@ -65,5 +78,28 @@ LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
6578
LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)"
6679
[ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS"
6780

81+
## node post v1.0/io.js merger ##
82+
nvm_ls_remote() {
83+
echo "v0.4.3"
84+
echo "v0.5.4"
85+
echo "v0.6.6"
86+
echo "v0.7.7"
87+
echo "v0.9.7"
88+
echo "v0.4.3"
89+
echo "v0.5.4"
90+
echo "v0.6.6"
91+
echo "v0.7.7"
92+
echo "v0.9.7"
93+
echo "v1.0.0"
94+
echo "v1.1.0"
95+
}
96+
97+
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
98+
[ "_$LATEST_STABLE" = "_1.1" ] || die "remote stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
99+
100+
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
101+
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd pre-v1.0 minor: expected 0.9, got $LATEST_UNSTABLE"
102+
## ** ##
103+
68104
cleanup
69105

0 commit comments

Comments
 (0)