2015-02-22 12:03:06 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
die () { echo $@ ; cleanup ; exit 1; }
|
|
|
|
cleanup () {
|
|
|
|
rm -rf "$(nvm_version_path v0.1.2)"
|
|
|
|
}
|
|
|
|
|
|
|
|
. ../../../nvm.sh
|
|
|
|
|
|
|
|
mkdir -p "$(nvm_version_path v0.1.2)"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"
|
|
|
|
EXIT_CODE=$?
|
2016-07-06 08:40:45 +08:00
|
|
|
EXPECTED_OUTPUT='N/A: version "foo" is not yet installed.
|
|
|
|
|
|
|
|
You need to run "nvm install foo" to install it before using it.'
|
2015-02-22 12:03:06 +08:00
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_ensure_version_installed 0.1)"
|
|
|
|
EXIT_CODE=$?
|
|
|
|
[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE"
|
|
|
|
|
2015-09-11 09:42:47 +08:00
|
|
|
# Special case for "iojs"
|
|
|
|
OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"
|
|
|
|
EXIT_CODE=$?
|
2016-07-06 08:40:45 +08:00
|
|
|
EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed.
|
|
|
|
|
|
|
|
You need to run "nvm install iojs" to install it before using it.'
|
2015-09-11 09:42:47 +08:00
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"
|
|
|
|
|
2015-02-22 12:03:06 +08:00
|
|
|
cleanup
|