nvm/test/installation_node/install from binary with bi...

38 lines
1.3 KiB
Bash

#!/bin/sh
die () { echo "$@" ; exit 1; }
\. ../../nvm.sh
nvm unalias default || die 'unable to unalias default'
NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
# Install from binary
nvm install -b $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed"
# Check
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
# ensure default is set
NVM_CURRENT_DEFAULT="$(nvm_alias default)"
[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)"
# Falls back to source but if -b is set fails binary download.
OUTPUT="$(nvm install -b 9.0.0 2>&1)"
EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'
if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then
die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"
fi
# Falls back to source but if -b is not set.
OUTPUT="$(nvm install 9.0.0 2>&1)"
EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'
if [ "${OUTPUT#*$EXPECTED_OUTPUT}" != "${OUTPUT}" ]; then
die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"
fi