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.
17 lines
532 B
Bash
Executable File
17 lines
532 B
Bash
Executable File
#!/bin/sh
|
|
|
|
\. ../../common.sh
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"
|
|
OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)"
|
|
EXIT_CODE="$?"
|
|
[ "_$(echo "$OUTPUT" | strip_colors)" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT""
|
|
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_ensure_default_set' did not exit with 1, got "$EXIT_CODE""
|
|
|
|
# see test/fast/Aliases for remaining nvm_ensure_default_set tests
|