Skip to content
Myr

Merge pull request #1145 from robotlolita/patch-missing-version-error

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

`nvm install`: Improve error messages for missing versions

authored by Jordan Harband · committed by GitHub · parents 322d81d, 730b253 · Browse files · 3 files+21 added−6 removed
This commit

State

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

Diff stats

3 files+21 added−6 removed

  • tests:+15 added−4 removed
  • other:+6 added−2 removed

3 files+21 added−6 removed

modified:test/fast/Unit tests/nvm_ensure_version_installed+6 added-2 removed
9 unmodified lines
10mkdir -p "$(nvm_version_path v0.1.2)"1112OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"13EXIT_CODE=$?14EXPECTED_OUTPUT='N/A: version "foo" is not yet installed'14EXPECTED_OUTPUT='N/A: version "foo" is not yet installed.1516You need to run "nvm install foo" to install it before using it.'17[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"18[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"1920OUTPUT="$(nvm_ensure_version_installed 0.1)"
3 unmodified lines
2425# Special case for "iojs"26OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"27EXIT_CODE=$?26EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed'28EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed.2930You need to run "nvm install iojs" to install it before using it.'31[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"32[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"3334cleanup
modified:test/slow/nvm run/Running "nvm run 0.x" should error out sensibly when 0.x is not installed+9 added-2 removed
3 unmodified lines
4die () { echo $@ ; exit 1; }56. ../../../nvm.sh78[ "$(nvm run 0.2 --version 2>&1)" = 'N/A: version "v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"9[ "$(nvm run iojs-0.2 --version 2>&1)" = 'N/A: version "iojs-v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"8EXPECTED_OUTPUT='N/A: version "v0.2" is not yet installed.910You need to run "nvm install 0.2" to install it before using it.'11[ "_$(nvm run 0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"1213EXPECTED_OUTPUT='N/A: version "iojs-v0.2" is not yet installed.1415You need to run "nvm install iojs-0.2" to install it before using it.'16[ "_$(nvm run iojs-0.2 --version 2>&1)" = "_$EXPECTED_OUTPUT" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"
modified:nvm.sh+6 added-2 removed
254 unmodified lines
255 local NVM_VERSION_DIR256 if [ "_$EXIT_CODE" != "_0" ] || ! nvm_is_version_installed "$LOCAL_VERSION"; then257 VERSION="$(nvm_resolve_alias "$PROVIDED_VERSION")"258 if [ $? -eq 0 ]; then259 nvm_err "N/A: version \"$PROVIDED_VERSION -> $VERSION\" is not yet installed"259 nvm_err "N/A: version \"$PROVIDED_VERSION -> $VERSION\" is not yet installed."260 nvm_err ""261 nvm_err "You need to run \"nvm install $PROVIDED_VERSION\" to install it before using it."262 else263 local PREFIXED_VERSION264 PREFIXED_VERSION="$(nvm_ensure_version_prefix "$PROVIDED_VERSION")"263 nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed"265 nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."266 nvm_err ""267 nvm_err "You need to run \"nvm install $PROVIDED_VERSION\" to install it before using it."268 fi269 return 1270 fi271}
2372 unmodified lines