[New] select versions by category: alpha, lts, non-lts, iojs; exclude alphas by default

Node 27 and later publish Alpha prereleases, like `v27.0.0-alpha.1.0.0`, in the main `index.tab`,
so `nvm install node` or `nvm install 27` would otherwise pick one.
Every version is in exactly one category: `alpha` and `lts` or `non-lts` (by index.tab's LTS column) on the node mirror, and `iojs` on the io.js mirror.
Commands select from every category but `alpha`, unless `$NVM_ONLY` lists others,
and every command that selects or lists versions takes `--only=<categories>` to override both;
an exact alpha needs `alpha` selected, like any other.
An LTS selection, like `--lts` or an `lts/` version, can't combine with an `--only=` that excludes `lts`.
Telling installed `lts` and `non-lts` versions apart uses the recorded LTS status, and fails rather than guess without it.
`nvm alias` also stores `--only=`, so `nvm alias default --only=alpha node` makes the latest installed alpha the default, including in a new shell.
This commit is contained in:
Jordan Harband committed 2026-10-21 14:09:18 -07:00
1 parent 11df5ed6f1
commit 3fda4d5542
13 files changed
+1213 -51

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh
for PAIR in 'alpha:alpha' 'iojs,lts:lts,iojs' 'non-lts,alpha,iojs,lts:alpha,lts,non-lts,iojs' 'lts,lts,non-lts,lts:lts,non-lts'; do
try nvm_normalize_only "${PAIR%%:*}" 'SOURCE'
[ "_${CAPTURED_EXIT_CODE}" = '_0' ] || die "nvm_normalize_only ${PAIR%%:*} exited ${CAPTURED_EXIT_CODE}"
[ "_${CAPTURED_STDOUT}" = "_${PAIR#*:}" ] || die "nvm_normalize_only ${PAIR%%:*} printed >${CAPTURED_STDOUT}<, expected >${PAIR#*:}<"
done
for VALUE in '' 'beta' 'lts,beta' ',lts' 'lts,' 'lts,,iojs' 'LTS' 'lts non-lts' 'nonlts' 'all'; do
try_err nvm_normalize_only "${VALUE}" 'SOURCE'
[ "_${CAPTURED_EXIT_CODE}" = '_55' ] || die "nvm_normalize_only >${VALUE}< exited ${CAPTURED_EXIT_CODE}, expected 55"
EXPECTED="Invalid SOURCE value \"${VALUE}\": it must be a comma-separated list of any of: alpha, lts, non-lts, iojs"
[ "_${CAPTURED_STDERR}" = "_${EXPECTED}" ] || die "nvm_normalize_only >${VALUE}< printed >${CAPTURED_STDERR}<, expected >${EXPECTED}<"
try nvm_normalize_only "${VALUE}" 'SOURCE'
[ -z "${CAPTURED_STDOUT}" ] || die "nvm_normalize_only >${VALUE}< printed >${CAPTURED_STDOUT}< to stdout"
done