From 14acd3dcdd400fba1e4c2b361a8d3a042aa637e2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 1 Aug 2024 10:35:37 -0700 Subject: [PATCH] [Fix] `nvm install -b`: do not attempt to download source on a failed binary download with `-b` Fixes #3399 --- nvm.sh | 4 ++-- test/fast/Unit tests/nvm install -b | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 15c8325f78..86aba61d77 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2437,7 +2437,7 @@ nvm_download_artifact() { nvm_err "Downloading ${TARBALL_URL}..." nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || ( command rm -rf "${TARBALL}" "${tmpdir}" - nvm_err "Binary download from ${TARBALL_URL} failed, trying source." + nvm_err "download from ${TARBALL_URL} failed" return 4 ) @@ -3564,7 +3564,7 @@ nvm() { fi fi - if [ $EXIT_CODE -ne 0 ]; then + if [ $EXIT_CODE -ne 0 ] && [ $nosource -ne 1 ]; then if [ -z "${NVM_MAKE_JOBS-}" ]; then nvm_get_make_jobs fi diff --git a/test/fast/Unit tests/nvm install -b b/test/fast/Unit tests/nvm install -b index 66f65648d6..20b4b7672b 100755 --- a/test/fast/Unit tests/nvm install -b +++ b/test/fast/Unit tests/nvm install -b @@ -4,6 +4,10 @@ die () { echo "$@" ; exit 1; } \. ../../../nvm.sh +nvm_install_source() { + exit 42 +} + VERSION="0.7.0" EXIT_CODE=$(nvm install -b "${VERSION}" ; echo $?)