nvm/test/fast/Aliases/Running "nvm alias" lists m...

50 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/bin/sh
. ../../../nvm.sh
. ../../common.sh
die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
2014-10-22 16:26:34 +08:00
rm -rf ../../../alias/stable
rm -rf ../../../alias/unstable
rm -rf ../../../alias/node
rm -rf ../../../alias/iojs
rm -rf ../../../v0.8.1
rm -rf ../../../v0.9.1
rm -rf ../../../versions/io.js/v0.2.1
}
mkdir ../../../v0.8.1
mkdir ../../../v0.9.1
mkdir -p ../../../versions/io.js/v0.2.1
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|| die "stable and unstable versions are the same!"
nvm alias stable "$EXPECTED_UNSTABLE"
nvm alias unstable "$EXPECTED_STABLE"
nvm alias node stable
nvm alias iojs unstable
NVM_ALIAS_OUTPUT=$(nvm alias | strip_colors)
echo "$NVM_ALIAS_OUTPUT" | command grep -F "stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)" \
|| die "nvm alias did not contain the overridden 'stable' alias; got '$NVM_ALIAS_OUTPUT'"
echo "$NVM_ALIAS_OUTPUT" | command grep -F "unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)" \
|| die "nvm alias did not contain the overridden 'unstable' alias; got '$NVM_ALIAS_OUTPUT'"
echo "$NVM_ALIAS_OUTPUT" | command grep -F "node -> stable (-> $UNSTABLE_VERSION)" \
|| die "nvm alias did not contain the overridden 'node' alias; got '$NVM_ALIAS_OUTPUT'"
echo "$NVM_ALIAS_OUTPUT" | command grep -F "iojs -> unstable (-> $STABLE_VERSION)" \
|| die "nvm alias did not contain the overridden 'iojs' alias; got '$NVM_ALIAS_OUTPUT'"
cleanup