mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 08:52:48 +08:00
nvm.sh uses `NVM_SCRIPT_SOURCE="$_"` to detect its source location. Adding `: nvm.sh` before each source line ensures `$_` is set correctly, preventing breakage when the previous command (e.g., `set -ex`) overwrites it.
22 lines
528 B
Bash
Executable File
22 lines
528 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -x
|
|
: nvm.sh
|
|
\. ../../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}<"
|