Files
nvm/test/fast/Listing versions/Running 'nvm ls default' should show system version when available
Peter Dave Hello 29a652f90f [patch] show system Node.js version in nvm ls
Normalize `nvm_version` output when `nvm_ls` returns "system vX" so alias and .nvmrc resolutions treat system correctly.

Add fast tests for system alias behavior in `nvm ls`, `nvm use`, and `nvm which`.
2026-01-25 18:19:50 +08:00

23 lines
553 B
Bash
Executable File

#!/bin/sh
die () { echo "$@" ; cleanup ; exit 1; }
cleanup () {
rm -f "$(nvm_alias_path)/default"
unset -f nvm_has_system_node node
}
\. ../../../nvm.sh
\. ../../common.sh
nvm_make_alias default system
nvm_has_system_node() { return 0; }
node() { command printf 'v0.0.0'; }
OUTPUT="$(nvm ls default | strip_colors)"
echo "${OUTPUT}" | command grep -q 'system' \
|| die "Could not list system via alias. Got >${OUTPUT}<"
echo "${OUTPUT}" | command grep -q 'v0.0.0' \
|| die "Could not list system version via alias. Got >${OUTPUT}<"
cleanup