[Fix] nvm exec: Do a version check on nvm-exec

This check would display a message in case the `.nvmrc` version is not installed, and would not alter the output otherwise.
This commit is contained in:
Bark
2024-03-06 16:03:10 +02:00
committed by Jordan Harband
parent 0fbe3a6776
commit 01a8749d7f
3 changed files with 30 additions and 7 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -x
\. ../../nvm.sh
die () { echo "$@" ; rm .nvmrc ; exit 1; }
NVM_TEST_VERSION=v0.42
# Write it to nvmrc
echo "$NVM_TEST_VERSION" > .nvmrc
OUTPUT="$(../../nvm-exec 2>&1)";
EXPECTED="N/A: version \"${NVM_TEST_VERSION}\" is not yet installed.
You need to run \`nvm install ${NVM_TEST_VERSION}\` to install and use it.
No NODE_VERSION provided; no .nvmrc file found";
# Skip install, we want to test the error message
[ "${EXPECTED}" = "${OUTPUT}" ] || die "expected >${EXPECTED}<, got >${OUTPUT}<"