Add support for `node` and `iojs` implicit aliases.
parent
d0617b5b79
commit
3190effedd
117
nvm.sh
117
nvm.sh
|
@ -218,16 +218,16 @@ nvm_remote_version() {
|
||||||
PATTERN="$1"
|
PATTERN="$1"
|
||||||
local VERSION
|
local VERSION
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
VERSION="$(nvm_ls_remote "$PATTERN")"
|
|
||||||
else
|
|
||||||
case "_$PATTERN" in
|
case "_$PATTERN" in
|
||||||
"_$(nvm_node_prefix)")
|
"_$(nvm_iojs_prefix)")
|
||||||
VERSION="$(nvm_ls_remote stable)"
|
VERSION="$(nvm_ls_remote_iojs | tail -n1)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
VERSION="$(nvm_remote_versions "$PATTERN" | tail -n1)"
|
VERSION="$(nvm_ls_remote "$PATTERN")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
else
|
||||||
|
VERSION="$(nvm_remote_versions "$PATTERN" | tail -n1)"
|
||||||
fi
|
fi
|
||||||
echo "$VERSION"
|
echo "$VERSION"
|
||||||
if [ "_$VERSION" = '_N/A' ]; then
|
if [ "_$VERSION" = '_N/A' ]; then
|
||||||
|
@ -236,20 +236,24 @@ nvm_remote_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_remote_versions() {
|
nvm_remote_versions() {
|
||||||
|
local NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
local PATTERN
|
local PATTERN
|
||||||
PATTERN="$1"
|
PATTERN="$1"
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if [ "_$PATTERN" = "_io.js" ]; then
|
||||||
echo >&2 "Implicit aliases are not supported in nvm_remote_versions."
|
PATTERN="$NVM_IOJS_PREFIX"
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
case "_$PATTERN" in
|
case "_$PATTERN" in
|
||||||
"_$(nvm_iojs_prefix)" | "_io.js")
|
"_$NVM_IOJS_PREFIX")
|
||||||
VERSIONS="$(nvm_ls_remote_iojs)"
|
VERSIONS="$(nvm_ls_remote_iojs)"
|
||||||
;;
|
;;
|
||||||
"_$(nvm_node_prefix)")
|
"_$(nvm_node_prefix)")
|
||||||
VERSIONS="$(nvm_ls_remote)"
|
VERSIONS="$(nvm_ls_remote)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
|
echo >&2 "Implicit aliases are not supported in nvm_remote_versions."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
VERSIONS="$(echo "$(nvm_ls_remote "$PATTERN")
|
VERSIONS="$(echo "$(nvm_ls_remote "$PATTERN")
|
||||||
$(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')"
|
$(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')"
|
||||||
;;
|
;;
|
||||||
|
@ -469,10 +473,6 @@ nvm_ls() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if nvm_resolve_alias "$PATTERN"; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
local NVM_IOJS_PREFIX
|
local NVM_IOJS_PREFIX
|
||||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
local NVM_NODE_PREFIX
|
local NVM_NODE_PREFIX
|
||||||
|
@ -489,6 +489,9 @@ nvm_ls() {
|
||||||
PATTERN="$PATTERN-"
|
PATTERN="$PATTERN-"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
if nvm_resolve_alias "$PATTERN"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
PATTERN=$(nvm_ensure_version_prefix $PATTERN)
|
PATTERN=$(nvm_ensure_version_prefix $PATTERN)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -669,10 +672,20 @@ nvm_print_versions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_validate_implicit_alias() {
|
nvm_validate_implicit_alias() {
|
||||||
if [ "_$1" != "_stable" ] && [ "_$1" != "_unstable" ]; then
|
local NVM_IOJS_PREFIX
|
||||||
echo "Only implicit aliases 'stable' and 'unstable' are supported." >&2
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
return 1
|
local NVM_NODE_PREFIX
|
||||||
fi
|
NVM_NODE_PREFIX="$(nvm_node_prefix)"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"stable" | "unstable" | "$NVM_IOJS_PREFIX" | "$NVM_NODE_PREFIX" )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Only implicit aliases 'stable', 'unstable', '$NVM_IOJS_PREFIX', and '$NVM_NODE_PREFIX' are supported." >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_print_implicit_alias() {
|
nvm_print_implicit_alias() {
|
||||||
|
@ -685,18 +698,67 @@ nvm_print_implicit_alias() {
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local ZHS_HAS_SHWORDSPLIT_UNSET
|
||||||
|
|
||||||
|
local NVM_IOJS_PREFIX
|
||||||
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
|
local NVM_NODE_PREFIX
|
||||||
|
NVM_NODE_PREFIX="$(nvm_node_prefix)"
|
||||||
|
local NVM_COMMAND
|
||||||
local LAST_TWO
|
local LAST_TWO
|
||||||
if [ "_$1" = "_local" ]; then
|
case "$2" in
|
||||||
LAST_TWO=$(nvm_ls | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq)
|
"$NVM_IOJS_PREFIX")
|
||||||
else
|
NVM_COMMAND="nvm_ls_remote_iojs"
|
||||||
LAST_TWO=$(nvm_ls_remote | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq)
|
if [ "_$1" = "_local" ]; then
|
||||||
fi
|
NVM_COMMAND="nvm_ls iojs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ZHS_HAS_SHWORDSPLIT_UNSET=1
|
||||||
|
if nvm_has "setopt"; then
|
||||||
|
ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
|
||||||
|
setopt shwordsplit
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_IOJS_VERSION
|
||||||
|
NVM_IOJS_VERSION="$($NVM_COMMAND | sed "s/^"$NVM_IOJS_PREFIX"-//" | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq | tail -1)"
|
||||||
|
local EXIT_CODE
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
|
||||||
|
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||||
|
unsetopt shwordsplit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$(nvm_add_iojs_prefix "$NVM_IOJS_VERSION")"
|
||||||
|
return $EXIT_CODE
|
||||||
|
;;
|
||||||
|
"$NVM_NODE_PREFIX")
|
||||||
|
echo "stable"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
NVM_COMMAND="nvm_ls_remote"
|
||||||
|
if [ "_$1" = "_local" ]; then
|
||||||
|
NVM_COMMAND="nvm_ls node"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ZHS_HAS_SHWORDSPLIT_UNSET=1
|
||||||
|
if nvm_has "setopt"; then
|
||||||
|
ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
|
||||||
|
setopt shwordsplit
|
||||||
|
fi
|
||||||
|
|
||||||
|
LAST_TWO=$($NVM_COMMAND | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq)
|
||||||
|
|
||||||
|
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||||
|
unsetopt shwordsplit
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
local MINOR
|
local MINOR
|
||||||
local STABLE
|
local STABLE
|
||||||
local UNSTABLE
|
local UNSTABLE
|
||||||
local MOD
|
local MOD
|
||||||
|
|
||||||
local ZHS_HAS_SHWORDSPLIT_UNSET
|
|
||||||
ZHS_HAS_SHWORDSPLIT_UNSET=1
|
ZHS_HAS_SHWORDSPLIT_UNSET=1
|
||||||
if nvm_has "setopt"; then
|
if nvm_has "setopt"; then
|
||||||
ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
|
ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
|
||||||
|
@ -1189,12 +1251,11 @@ nvm() {
|
||||||
else
|
else
|
||||||
local NVM_IOJS_PREFIX
|
local NVM_IOJS_PREFIX
|
||||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
|
local NVM_NODE_PREFIX
|
||||||
|
NVM_NODE_PREFIX="$(nvm_node_prefix)"
|
||||||
case "_$2" in
|
case "_$2" in
|
||||||
"_$NVM_IOJS_PREFIX" | "_io.js")
|
"_$NVM_IOJS_PREFIX" | "_io.js")
|
||||||
VERSION="$(nvm_add_iojs_prefix $(nvm_ls | command grep "$NVM_IOJS_PREFIX" | tail -n1))"
|
VERSION="$(nvm_version $NVM_IOJS_PREFIX)"
|
||||||
;;
|
|
||||||
"_$(nvm_node_prefix)")
|
|
||||||
VERSION="$(nvm_version stable)"
|
|
||||||
;;
|
;;
|
||||||
"_system")
|
"_system")
|
||||||
VERSION="system"
|
VERSION="system"
|
||||||
|
@ -1469,7 +1530,7 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for ALIAS in "stable" "unstable"; do
|
for ALIAS in "$(nvm_node_prefix)" "stable" "unstable" "$(nvm_iojs_prefix)"; do
|
||||||
if [ ! -f "$NVM_ALIAS_DIR/$ALIAS" ]; then
|
if [ ! -f "$NVM_ALIAS_DIR/$ALIAS" ]; then
|
||||||
if [ $# -lt 2 ] || [ "~$ALIAS" = "~$2" ]; then
|
if [ $# -lt 2 ] || [ "~$ALIAS" = "~$2" ]; then
|
||||||
DEST="$(nvm_print_implicit_alias local "$ALIAS")"
|
DEST="$(nvm_print_implicit_alias local "$ALIAS")"
|
||||||
|
|
|
@ -11,8 +11,16 @@ STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
||||||
|| die "nvm alias did not contain the default local stable node version"
|
|| die "nvm alias did not contain the default local stable node version"
|
||||||
|
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^node -> stable (-> $STABLE_VERSION) (default)$" \
|
||||||
|
|| die "nvm alias did not contain the default local stable node version under 'node'"
|
||||||
|
|
||||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
||||||
|| die "nvm alias did not contain the default local unstable node version"
|
|| die "nvm alias did not contain the default local unstable node version"
|
||||||
|
|
||||||
|
EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||||
|
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)$" \
|
||||||
|
|| die "nvm alias did not contain the default local iojs version"
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,16 @@ die () { echo $@ ; cleanup ; exit 1; }
|
||||||
cleanup () {
|
cleanup () {
|
||||||
rm -rf ../../../alias/stable
|
rm -rf ../../../alias/stable
|
||||||
rm -rf ../../../alias/unstable
|
rm -rf ../../../alias/unstable
|
||||||
|
rm -rf ../../../alias/node
|
||||||
|
rm -rf ../../../alias/iojs
|
||||||
rm -rf ../../../v0.8.1
|
rm -rf ../../../v0.8.1
|
||||||
rm -rf ../../../v0.9.1
|
rm -rf ../../../v0.9.1
|
||||||
|
rm -rf ../../../versions/io.js/v0.2.1
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir ../../../v0.8.1
|
mkdir ../../../v0.8.1
|
||||||
mkdir ../../../v0.9.1
|
mkdir ../../../v0.9.1
|
||||||
|
mkdir -p ../../../versions/io.js/v0.2.1
|
||||||
|
|
||||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||||
|
@ -24,14 +28,22 @@ UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||||
|
|
||||||
nvm alias stable "$EXPECTED_UNSTABLE"
|
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||||
nvm alias unstable "$EXPECTED_STABLE"
|
nvm alias unstable "$EXPECTED_STABLE"
|
||||||
|
nvm alias node stable
|
||||||
|
nvm alias iojs unstable
|
||||||
|
|
||||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||||
|
|
||||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||||
|| die "nvm alias did not contain the overridden 'stable' alias"
|
|| die "nvm alias did not contain the overridden 'stable' alias"
|
||||||
|
|
||||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||||
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
||||||
|
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^node -> stable (-> $UNSTABLE_VERSION)$" \
|
||||||
|
|| die "nvm alias did not contain the overridden 'node' alias"
|
||||||
|
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^iojs -> unstable (-> $STABLE_VERSION)$" \
|
||||||
|
|| die "nvm alias did not contain the overridden 'iojs' alias"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,11 @@ EXIT_CODE=$(nvm_resolve_alias nonexistent ; echo $?)
|
||||||
STABLE="$(nvm_resolve_alias stable)"
|
STABLE="$(nvm_resolve_alias stable)"
|
||||||
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_alias stable' was not v0.0.10; got $STABLE"
|
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_alias stable' was not v0.0.10; got $STABLE"
|
||||||
|
|
||||||
|
NODE="$(nvm_resolve_alias node)"
|
||||||
|
[ "_$NODE" = "_v0.0.10" ] || die "'nvm_resolve_alias node' was not v0.0.10; got $NODE"
|
||||||
|
|
||||||
UNSTABLE="$(nvm_resolve_alias unstable)"
|
UNSTABLE="$(nvm_resolve_alias unstable)"
|
||||||
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_alias unstable' was not v0.1.10; got $UNSTABLE"
|
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_alias unstable' was not v0.1.10; got $UNSTABLE"
|
||||||
|
|
||||||
|
IOJS="$(nvm_resolve_alias iojs)"
|
||||||
|
[ "_$IOJS" = "_iojs-v0.2.10" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2.10; got $IOJS"
|
||||||
|
|
|
@ -6,4 +6,6 @@ for i in $(seq 1 10)
|
||||||
mkdir -p ../../../v0.0.$i
|
mkdir -p ../../../v0.0.$i
|
||||||
echo 0.1.$i > ../../../alias/test-unstable-$i
|
echo 0.1.$i > ../../../alias/test-unstable-$i
|
||||||
mkdir -p ../../../v0.1.$i
|
mkdir -p ../../../v0.1.$i
|
||||||
|
echo 0.2.$i > ../../../alias/test-iojs-$i
|
||||||
|
mkdir -p ../../../versions/io.js/v0.2.$i
|
||||||
done
|
done
|
||||||
|
|
|
@ -6,8 +6,11 @@ for i in $(seq 1 10)
|
||||||
rm -rf "../../../v0.0.$i"
|
rm -rf "../../../v0.0.$i"
|
||||||
rm -f "../../../alias/test-unstable-$i"
|
rm -f "../../../alias/test-unstable-$i"
|
||||||
rm -rf "../../../v0.1.$i"
|
rm -rf "../../../v0.1.$i"
|
||||||
|
rm -rf "../../../alias/test-iojs-$i"
|
||||||
|
rm -rf "../../../versions/io.js/v0.2.$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f "../../../alias/stable"
|
rm -f "../../../alias/stable"
|
||||||
rm -f "../../../alias/unstable"
|
rm -f "../../../alias/unstable"
|
||||||
|
rm -f "../../../alias/node"
|
||||||
|
rm -f "../../../alias/iojs"
|
||||||
|
|
|
@ -14,13 +14,13 @@ FIRST_EXIT_CODE="$(nvm_print_implicit_alias > /dev/null 2>&1 ; echo $?)"
|
||||||
[ "_$FIRST_EXIT_CODE" = "_1" ] \
|
[ "_$FIRST_EXIT_CODE" = "_1" ] \
|
||||||
|| die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE"
|
|| die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE"
|
||||||
|
|
||||||
EXPECTED_SECOND_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
EXPECTED_SECOND_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
|
||||||
[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||||
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
|
||||||
[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||||
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
|
||||||
|
|
||||||
SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)"
|
SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)"
|
||||||
[ "_$SECOND_EXIT_CODE" = "_2" ] \
|
[ "_$SECOND_EXIT_CODE" = "_2" ] \
|
||||||
|| die "nvm_print_implicit_alias without stable|unstable had wrong exit code: expected 2, got $SECOND_EXIT_CODE"
|
|| die "nvm_print_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 2, got $SECOND_EXIT_CODE"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ cleanup() {
|
||||||
rm -rf ../../../v0.4.6
|
rm -rf ../../../v0.4.6
|
||||||
rm -rf ../../../v0.5.7
|
rm -rf ../../../v0.5.7
|
||||||
rm -rf ../../../v0.7.7
|
rm -rf ../../../v0.7.7
|
||||||
unset -f nvm_ls_remote
|
rm -rf ../../../versions/io.js/v0.98.0
|
||||||
|
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||||
}
|
}
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
@ -17,13 +18,20 @@ mkdir ../../../v0.3.4
|
||||||
mkdir ../../../v0.4.6
|
mkdir ../../../v0.4.6
|
||||||
mkdir ../../../v0.5.7
|
mkdir ../../../v0.5.7
|
||||||
mkdir ../../../v0.7.7
|
mkdir ../../../v0.7.7
|
||||||
|
mkdir -p ../../../versions/io.js/v0.98.0
|
||||||
|
|
||||||
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
[ "_$LATEST_STABLE" = "_0.4" ] || die "local stable is not latest even minor: expected 0.4, got $LATEST_STABLE"
|
[ "_$LATEST_STABLE" = "_0.4" ] || die "local stable is not latest even minor: expected 0.4, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_NODE="$(nvm_print_implicit_alias local node)"
|
||||||
|
[ "_$LATEST_NODE" = "_stable" ] || die "local node is not stable: expected stable, got $LATEST_NODE"
|
||||||
|
|
||||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest odd minor: expected 0.7, got $LATEST_UNSTABLE"
|
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest odd minor: expected 0.7, got $LATEST_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"
|
||||||
|
|
||||||
nvm_ls_remote() {
|
nvm_ls_remote() {
|
||||||
echo "v0.4.3"
|
echo "v0.4.3"
|
||||||
echo "v0.5.4"
|
echo "v0.5.4"
|
||||||
|
@ -37,11 +45,25 @@ nvm_ls_remote() {
|
||||||
echo "v0.9.7"
|
echo "v0.9.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_ls_remote_iojs() {
|
||||||
|
echo "iojs-v0.1.0"
|
||||||
|
echo "iojs-v0.1.1"
|
||||||
|
echo "iojs-v0.7.8"
|
||||||
|
echo "iojs-v0.98.5"
|
||||||
|
echo "iojs-v0.99.0"
|
||||||
|
}
|
||||||
|
|
||||||
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
||||||
[ "_$LATEST_STABLE" = "_0.6" ] || die "remote stable is not latest even minor: expected 0.6, got $LATEST_STABLE"
|
[ "_$LATEST_STABLE" = "_0.6" ] || die "remote stable is not latest even minor: expected 0.6, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_NODE="$(nvm_print_implicit_alias remote node)"
|
||||||
|
[ "_$LATEST_NODE" = "_stable" ] || die "remote node is not stable: expected stable, got $LATEST_NODE"
|
||||||
|
|
||||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
||||||
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd minor: expected 0.9, got $LATEST_UNSTABLE"
|
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd minor: expected 0.9, got $LATEST_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"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ nvm_ls_remote() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
nvm_ls_remote_iojs() {
|
nvm_ls_remote_iojs() {
|
||||||
if nvm_is_iojs_version "$1"; then
|
if [ -z "$1" ] || nvm_is_iojs_version "$1"; then
|
||||||
echo "test iojs output"
|
echo "test iojs output"
|
||||||
echo "more iojs test output"
|
echo "more iojs test output"
|
||||||
echo "iojs pattern received: _$1_"
|
echo "iojs pattern received: _$1_"
|
||||||
|
@ -51,11 +51,28 @@ EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||||
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
|
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
|
||||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_version iojs)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version iojs >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_iojs pattern received: __" ] \
|
||||||
|
|| die "nvm_remote_version iojs did not return last line only of nvm_ls_remote_iojs; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
OUTPUT="$(nvm_remote_version stable)"
|
OUTPUT="$(nvm_remote_version stable)"
|
||||||
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
|
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
|
||||||
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|
||||||
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
|
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
|
||||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
cleanup
|
OUTPUT="$(nvm_remote_version unstable)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version unstable >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote unstable)" ] \
|
||||||
|
|| die "nvm_remote_version unstable did not return contents of nvm_ls_remote unstable; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version unstable did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_version node)"
|
||||||
|
EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote node)" ] \
|
||||||
|
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
|
@ -4,16 +4,18 @@ die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
EXPECTED_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
EXPECTED_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
|
||||||
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
|
||||||
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
|
||||||
|
|
||||||
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
|
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
|
||||||
[ "_$EXIT_CODE" = "_1" ] \
|
[ "_$EXIT_CODE" = "_1" ] \
|
||||||
|| die "nvm_validate_implicit_alias without stable|unstable had wrong exit code: expected 1, got $EXIT_CODE"
|
|| die "nvm_validate_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 1, got $EXIT_CODE"
|
||||||
|
|
||||||
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
|
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
|
||||||
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
|
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
|
||||||
|
nvm_validate_implicit_alias node || die "nvm_validate_implicit_alias node did not exit 0"
|
||||||
|
nvm_validate_implicit_alias iojs || die "nvm_validate_implicit_alias iojs did not exit 0"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue