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
Provenance
- Commit
f3ce324- Tree
c70abf4- Author
Jordan Harband <ljharb@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
322d81d- Parent 2
730b253
3 files changed+21 added−6 removed
modified:test/fast/Unit tests/nvm_ensure_version_installed+6 added-2 removed
9 unmodified lines10 mkdir -p "$(nvm_version_path v0.1.2)"11 12 OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"13 EXIT_CODE=$?14-EXPECTED_OUTPUT='N/A: version "foo" is not yet installed'14+EXPECTED_OUTPUT='N/A: version "foo" is not yet installed.15+16+You 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"19 20 OUTPUT="$(nvm_ensure_version_installed 0.1)"3 unmodified lines24 25 # Special case for "iojs"26 OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"27 EXIT_CODE=$?26-EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed'28+EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed.29+30+You 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"33 34 cleanupmodified: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 lines4 die () { echo $@ ; exit 1; }5 6 . ../../../nvm.sh7 8-[ "$(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"8+EXPECTED_OUTPUT='N/A: version "v0.2" is not yet installed.9+10+You 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"12+13+EXPECTED_OUTPUT='N/A: version "iojs-v0.2" is not yet installed.14+15+You 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 lines255 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