2014-09-29 15:09:17 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../../nvm.sh
|
|
|
|
\. ../../common.sh
|
2014-09-29 15:09:17 +08:00
|
|
|
|
|
|
|
die () { echo $@ ; cleanup ; exit 1; }
|
|
|
|
cleanup () {
|
2016-06-27 06:52:26 +08:00
|
|
|
rm -rf "$(nvm_alias_path)/stable"
|
|
|
|
rm -rf "$(nvm_alias_path)/unstable"
|
|
|
|
rm -rf "$(nvm_alias_path)/node"
|
|
|
|
rm -rf "$(nvm_alias_path)/iojs"
|
|
|
|
rm -rf "${NVM_DIR}/v0.8.1"
|
|
|
|
rm -rf "${NVM_DIR}/v0.9.1"
|
|
|
|
rm -rf "${NVM_DIR}/versions/io.js/v0.2.1"
|
2014-09-29 15:09:17 +08:00
|
|
|
}
|
|
|
|
|
2016-06-27 06:52:26 +08:00
|
|
|
mkdir "${NVM_DIR}/v0.8.1"
|
|
|
|
mkdir "${NVM_DIR}/v0.9.1"
|
|
|
|
mkdir -p "${NVM_DIR}/versions/io.js/v0.2.1"
|
2014-09-29 15:09:17 +08:00
|
|
|
|
|
|
|
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"
|
2015-02-11 06:41:45 +08:00
|
|
|
nvm alias node stable
|
|
|
|
nvm alias iojs unstable
|
2014-09-29 15:09:17 +08:00
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
NVM_ALIAS_OUTPUT=$(nvm alias | strip_colors)
|
2014-09-29 15:09:17 +08:00
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
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'"
|
2014-09-29 15:09:17 +08:00
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
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'"
|
2014-09-29 15:09:17 +08:00
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
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'"
|
2015-02-11 06:41:45 +08:00
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
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'"
|
2015-02-11 06:41:45 +08:00
|
|
|
|
2014-09-29 15:09:17 +08:00
|
|
|
cleanup
|