Skip to content

Commit 3c4669d

Browse files
committed
[Fix] nvm install -b: when no binary is available, fail and output a clear message
1 parent f027a29 commit 3c4669d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

nvm.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,10 @@ nvm() {
35583558
EXIT_CODE=$?
35593559
else
35603560
EXIT_CODE=-1
3561+
if [ $nosource -eq 1 ]; then
3562+
nvm_err "Binary download is not available for ${VERSION}"
3563+
EXIT_CODE=999
3564+
fi
35613565
fi
35623566

35633567
if [ $EXIT_CODE -ne 0 ]; then

test/fast/Unit tests/nvm install -b

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
die () { echo "$@" ; exit 1; }
4+
5+
\. ../../nvm.sh
6+
7+
VERSION="0.7.0"
8+
9+
EXIT_CODE=$(nvm install -b "${VERSION}" ; echo $?)
10+
11+
[ $EXIT_CODE -eq 999 ] || die "Expected exit code 999, got ${EXIT_CODE}"
12+
13+
ACTUAL="$(nvm install -b "${VERSION}" 2>&1)"
14+
EXPECTED="Binary download is not available for ${VERSION}"
15+
16+
diff $ACTUAL $EXPECTED || die

0 commit comments

Comments
 (0)