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
434 B
Bash
Executable File
22 lines
434 B
Bash
Executable File
#!/bin/sh
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
nvm_install_source() {
|
|
exit 42
|
|
}
|
|
|
|
VERSION="0.7.0"
|
|
|
|
EXIT_CODE=$(nvm install -b "${VERSION}" ; echo $?)
|
|
|
|
[ $EXIT_CODE -eq 3 ] || die "Expected exit code 3, got ${EXIT_CODE}"
|
|
|
|
ACTUAL="$(nvm install -b "${VERSION}" 2>&1)"
|
|
EXPECTED="Binary download is not available for v${VERSION}"
|
|
|
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "Expected >${EXPECTED}<, got >${ACTUAL}<"
|