Skip to content
Myr

[Fix] `nvm_ensure_version_installed`: add `system` support.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Relates to #1238

authored by Jordan Harband · committed by Jordan Harband · parent 5776cc9 · Browse files · 2 files+35 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+35 added−0 removed

  • tests:+28 added−0 removed
  • other:+7 added−0 removed

2 files+35 added−0 removed

modified:test/fast/Unit tests/nvm_ensure_version_installed+28 added
1 unmodified line
23die () { echo "$@" ; cleanup ; exit 1; }4cleanup () {5 rm -rf "$(nvm_version_path v0.1.2)"6 unset -f nvm_has_system_node nvm_has_system_iojs7}89\. ../../../nvm.sh10
20 unmodified lines
31You need to run "nvm install iojs" to install it before using it.'32[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"33[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"3435nvm_has_system_node() { return 1; }36nvm_has_system_iojs() { return 1; }3738OUTPUT="$(nvm_ensure_version_installed system 2>&1)"39EXIT_CODE=$?40EXPECTED_OUTPUT='N/A: no system version of node/io.js is installed.'41[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed system' with neither installed to give $EXPECTED_OUTPUT, got $OUTPUT"42[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed system' with neither installed to exit with 1, got $EXIT_CODE"4344nvm_has_system_node() { return 0; }45nvm_has_system_iojs() { return 1; }4647OUTPUT="$(nvm_ensure_version_installed system 2>&1)"48EXIT_CODE=$?49EXPECTED_OUTPUT=''50[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed system' with node installed to give $EXPECTED_OUTPUT, got $OUTPUT"51[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed system' with node installed to exit with 0, got $EXIT_CODE"5253nvm_has_system_node() { return 1; }54nvm_has_system_iojs() { return 0; }5556OUTPUT="$(nvm_ensure_version_installed system 2>&1)"57EXIT_CODE=$?58EXPECTED_OUTPUT=''59[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed system' with iojs installed to give $EXPECTED_OUTPUT, got $OUTPUT"60[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed system' with iojs installed to exit with 0, got $EXIT_CODE"6162cleanup
modified:nvm.sh+7 added
287 unmodified lines
288289nvm_ensure_version_installed() {290 local PROVIDED_VERSION291 PROVIDED_VERSION="${1-}"292 if [ "${PROVIDED_VERSION}" = 'system' ]; then293 if nvm_has_system_iojs || nvm_has_system_node; then294 return 0295 fi296 nvm_err "N/A: no system version of node/io.js is installed."297 return 1298 fi299 local LOCAL_VERSION300 local EXIT_CODE301 LOCAL_VERSION="$(nvm_version "${PROVIDED_VERSION}")"302 EXIT_CODE="$?"
3058 unmodified lines