mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 17:02: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.
27 lines
1.3 KiB
Bash
Executable File
27 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
OUTPUT="$(nvm unalias node 2>&1)"
|
|
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
|
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
|
|
|
OUTPUT="$(nvm unalias stable 2>&1)"
|
|
EXPECTED_OUTPUT="stable is a default (built-in) alias and cannot be deleted."
|
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
|
|
|
OUTPUT="$(nvm unalias unstable 2>&1)"
|
|
EXPECTED_OUTPUT="unstable is a default (built-in) alias and cannot be deleted."
|
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
|
|
|
OUTPUT="$(nvm unalias iojs 2>&1)"
|
|
EXPECTED_OUTPUT="iojs is a default (built-in) alias and cannot be deleted."
|
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
|
|
|
OUTPUT="$(nvm unalias system 2>&1)"
|
|
EXPECTED_OUTPUT="system is a default (built-in) alias and cannot be deleted."
|
|
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
|