Skip to content
Myr

[Fix] `nvm install -b`: when no binary is available, fail and output a clear message

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

authored by Jordan Harband · committed by Jordan Harband · parent 423ee82 · Browse files · 2 files+38 added−16 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+38 added−16 removed

  • tests:+16 added−0 removed
  • other:+22 added−16 removed

2 files+38 added−16 removed

added:test/fast/Unit tests/nvm install -b+16 added
1#!/bin/sh23die () { echo "$@" ; exit 1; }45\. ../../../nvm.sh67VERSION="0.7.0"89EXIT_CODE=$(nvm install -b "${VERSION}" ; echo $?)1011[ $EXIT_CODE -eq 3 ] || die "Expected exit code 3, got ${EXIT_CODE}"1213ACTUAL="$(nvm install -b "${VERSION}" 2>&1)"14EXPECTED="Binary download is not available for v${VERSION}"1516[ "${ACTUAL}" = "${EXPECTED}" ] || die "Expected >${EXPECTED}<, got >${ACTUAL}<"
modified:nvm.sh+22 added-16 removed
3556 unmodified lines
3557 NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_binary "${FLAVOR}" std "${VERSION}" "${nosource}"3558 EXIT_CODE=$?3559 else3560 EXIT_CODE=-13561 if [ $nosource -eq 1 ]; then3562 nvm_err "Binary download is not available for ${VERSION}"3563 EXIT_CODE=33564 fi3565 fi35663567 if [ $EXIT_CODE -ne 0 ]; then3568 if [ -z "${NVM_MAKE_JOBS-}" ]; then
9 unmodified lines
3578 fi3579 fi3580 fi35813582 if [ $EXIT_CODE -eq 0 ]; then3578 if [ $EXIT_CODE -eq 0 ] && nvm_use_if_needed "${VERSION}" && nvm_install_npm_if_needed "${VERSION}"; then3579 if [ -n "${LTS-}" ]; then3580 nvm_ensure_default_set "lts/${LTS}"3583 if nvm_use_if_needed "${VERSION}" && nvm_install_npm_if_needed "${VERSION}"; then3584 if [ -n "${LTS-}" ]; then3585 nvm_ensure_default_set "lts/${LTS}"3586 else3587 nvm_ensure_default_set "${provided_version}"3588 fi3589 if [ "${NVM_UPGRADE_NPM}" = 1 ]; then3590 nvm install-latest-npm3591 EXIT_CODE=$?3592 fi3593 if [ $EXIT_CODE -eq 0 ] && [ -z "${SKIP_DEFAULT_PACKAGES-}" ]; then3594 nvm_install_default_packages3595 fi3596 if [ $EXIT_CODE -eq 0 ] && [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_${REINSTALL_PACKAGES_FROM}" != "_N/A" ]; then3597 nvm reinstall-packages "${REINSTALL_PACKAGES_FROM}"3598 EXIT_CODE=$?3599 fi3600 else3582 nvm_ensure_default_set "${provided_version}"3583 fi3584 if [ "${NVM_UPGRADE_NPM}" = 1 ]; then3585 nvm install-latest-npm3601 EXIT_CODE=$?3602 fi3588 if [ $EXIT_CODE -eq 0 ] && [ -z "${SKIP_DEFAULT_PACKAGES-}" ]; then3589 nvm_install_default_packages3590 fi3591 if [ $EXIT_CODE -eq 0 ] && [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_${REINSTALL_PACKAGES_FROM}" != "_N/A" ]; then3592 nvm reinstall-packages "${REINSTALL_PACKAGES_FROM}"3593 EXIT_CODE=$?3594 fi3595 else3596 EXIT_CODE=$?3603 fi36043605 return $EXIT_CODE3606 ;;
974 unmodified lines