From 053e61553e0034798ad124efaf566b41f93af873 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 6be6bfba7e..7871784fff 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 $?)