Skip to content

Commit

Permalink
[Fix] nvm install -b: when no binary is available, fail and output …
Browse files Browse the repository at this point in the history
…a clear message
  • Loading branch information
ljharb committed Aug 1, 2024
1 parent f027a29 commit 3c4669d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3558,6 +3558,10 @@ nvm() {
EXIT_CODE=$?
else
EXIT_CODE=-1
if [ $nosource -eq 1 ]; then
nvm_err "Binary download is not available for ${VERSION}"
EXIT_CODE=999
fi
fi

if [ $EXIT_CODE -ne 0 ]; then
Expand Down
16 changes: 16 additions & 0 deletions test/fast/Unit tests/nvm install -b
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

die () { echo "$@" ; exit 1; }

\. ../../nvm.sh

VERSION="0.7.0"

EXIT_CODE=$(nvm install -b "${VERSION}" ; echo $?)

[ $EXIT_CODE -eq 999 ] || die "Expected exit code 999, got ${EXIT_CODE}"

ACTUAL="$(nvm install -b "${VERSION}" 2>&1)"
EXPECTED="Binary download is not available for ${VERSION}"

diff $ACTUAL $EXPECTED || die

0 comments on commit 3c4669d

Please sign in to comment.