2014-11-23 02:52:44 +08:00
#!/bin/sh
2016-07-07 15:00:59 +08:00
set -ex
2016-11-07 03:34:36 +08:00
die () { echo "$@" ; cleanup ; exit 1; }
2014-11-23 02:52:44 +08:00
cleanup () {
2016-06-27 06:52:26 +08:00
rm -rf "${NVM_DIR}/v0.10.4"
2014-11-23 02:52:44 +08:00
}
2016-11-04 13:15:18 +08:00
\. ../../nvm.sh
2018-06-14 01:38:19 +08:00
\. ../common.sh
2014-11-23 02:52:44 +08:00
2018-06-14 01:38:19 +08:00
make_fake_node v0.10.4
2016-06-27 06:52:26 +08:00
2014-11-23 02:52:44 +08:00
nvm deactivate >/dev/null 2>&1
2016-07-07 15:00:59 +08:00
set +ex # needed for stderr
2014-11-23 02:52:44 +08:00
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.11 2>&1)"
2016-07-07 15:00:59 +08:00
set -ex
2014-11-23 02:52:44 +08:00
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
2016-07-07 15:00:59 +08:00
set +e # TODO: fix
2014-11-23 02:52:44 +08:00
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.11 >/dev/null 2>&1; echo $?)"
2016-07-07 15:00:59 +08:00
set -e
[ $INSTALL_EXIT_CODE -eq 5 ] \
|| die ""nvm install --reinstall-packages-from" should exit with code 5 when given an uninstalled version, got ${INSTALL_EXIT_CODE}"
2014-11-23 02:52:44 +08:00
2016-07-07 15:00:59 +08:00
set +ex # needed for stderr
2014-11-23 02:52:44 +08:00
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 2>&1)"
2016-07-07 15:00:59 +08:00
set -ex
2014-11-23 02:52:44 +08:00
EXPECTED_ERROR_MSG="You can't reinstall global packages from the same version of node you're installing."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
2016-07-07 15:00:59 +08:00
set +e # TODO: fix
2014-11-23 02:52:44 +08:00
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
2016-07-07 15:00:59 +08:00
set -e
[ $INSTALL_EXIT_CODE -eq 4 ] \
2014-11-23 02:52:44 +08:00
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
2018-03-14 15:13:07 +08:00
set +ex # needed for stderr
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from 2>&1)"
set -ex
EXPECTED_ERROR_MSG='If --reinstall-packages-from is provided, it must point to an installed version of node using `=`.'
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
set +ex # needed for stderr
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from= 2>&1)"
set -ex
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
2016-06-27 06:52:26 +08:00
cleanup