[New] record every node version's LTS status

Each download of node's `index.tab` now merges every version's LTS codename, or `-`, into `$NVM_DIR/.lts-status`,
keeping versions that download doesn't list,
so the status of an installed version is known, and refreshed on every remote connection.
Only an index that includes LTS versions can start the record, so a nightly or release candidate mirror can't,
and `nvm_ensure_lts_status` downloads it once for versions installed before it was recorded.
`update_test_mocks.sh` writes the record of its `index.tab` mock to `nodejs.org-dist-lts-status.txt`.
This commit is contained in:
Jordan Harband committed 2026-10-21 12:52:04 -07:00
1 parent 4007c0d062
commit e5f1288b40
8 files changed
+917

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
# gitignore
HEAD
.cache
.lts-status
v*
alias
+56
View File
@@ -2239,6 +2239,55 @@ nvm_ls_remote_iojs() {
NVM_LTS="${NVM_LTS-}" nvm_ls_remote_index_tab iojs std "${1-}"
}
# Every node version's LTS codename, or `-` when it isn't LTS, as of the latest index.tab
# that listed it. Versions it doesn't list have never been in an index.tab, so aren't LTS.
nvm_lts_status_path() {
nvm_echo "${NVM_DIR}/.lts-status"
}
# Records LTS status from node index.tab rows on stdin, keeping versions they don't list.
# Only rows that include an LTS version, unlike a nightly or release candidate index,
# can start the record, since every version they don't list counts as not LTS.
nvm_record_lts_status() {
local NVM_LTS_STATUS_PATH
NVM_LTS_STATUS_PATH="$(nvm_lts_status_path)"
local NVM_LTS_STATUS_TMP
NVM_LTS_STATUS_TMP="$(command mktemp "${NVM_LTS_STATUS_PATH}.XXXXXX" 2>/dev/null)" || return 1
# anything without a full row, like an error page, is not an index
if command awk -v previous="${NVM_LTS_STATUS_PATH}" '
NF >= 10 && $1 ~ /^v[0-9]+\.[0-9]+\.[0-9]+/ {
if (!($1 in lts)) { versions[++rows] = $1 }
lts[$1] = ($10 ~ /^-?$/ ? "-" : tolower($10));
if (lts[$1] != "-") { has_lts = 1 }
}
END {
if (!rows) { exit 1 }
if (!has_lts && (getline line < previous) <= 0) { exit 1 }
close(previous);
while ((getline line < previous) > 0) {
split(line, fields, " ");
if (!(fields[1] in lts)) { print fields[1], fields[2] }
}
for (i = 1; i <= rows; i++) { print versions[i], lts[versions[i]] }
}
' > "${NVM_LTS_STATUS_TMP}"; then
command mv -f "${NVM_LTS_STATUS_TMP}" "${NVM_LTS_STATUS_PATH}" 2>/dev/null && return 0
fi
command rm -f "${NVM_LTS_STATUS_TMP}"
return 1
}
# Versions installed before LTS status was recorded need one download of index.tab.
nvm_ensure_lts_status() {
if [ -f "$(nvm_lts_status_path)" ]; then
return 0
elif [ "${NVM_OFFLINE-}" = 1 ]; then
return 3
fi
NVM_LTS='' nvm_ls_remote_index_tab node std '' >/dev/null 2>&1
[ -f "$(nvm_lts_status_path)" ]
}
# args flavor, type, version
nvm_ls_remote_index_tab() {
local LTS
@@ -2333,6 +2382,12 @@ nvm_ls_remote_index_tab() {
$VERSION_LIST
EOF
if [ "${FLAVOR}" = 'node' ] && [ -n "${VERSION_LIST}" ]; then
nvm_record_lts_status << EOF ||:
$VERSION_LIST
EOF
fi
if [ -n "${LTS-}" ]; then
LTS="$(nvm_normalize_lts "lts/${LTS}")" || return $?
LTS="${LTS#lts/}"
@@ -5727,6 +5782,7 @@ nvm() {
nvm_is_iojs_version nvm_is_alias nvm_has_non_aliased \
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab nvm_get_remote_aliases \
nvm_ls nvm_remote_version nvm_remote_versions nvm_sort_versions \
nvm_lts_status_path nvm_record_lts_status nvm_ensure_lts_status \
nvm_install_binary nvm_install_source nvm_clang_version \
nvm_get_mirror nvm_get_download_slug nvm_download_artifact nvm_is_cached_artifact \
nvm_install_npm_if_needed nvm_use_if_needed nvm_check_file_permissions \
@@ -0,0 +1,759 @@
v23.1.0 -
v23.0.0 -
v22.11.0 jod
v22.10.0 -
v22.9.0 -
v22.8.0 -
v22.7.0 -
v22.6.0 -
v22.5.1 -
v22.5.0 -
v22.4.1 -
v22.4.0 -
v22.3.0 -
v22.2.0 -
v22.1.0 -
v22.0.0 -
v21.7.3 -
v21.7.2 -
v21.7.1 -
v21.7.0 -
v21.6.2 -
v21.6.1 -
v21.6.0 -
v21.5.0 -
v21.4.0 -
v21.3.0 -
v21.2.0 -
v21.1.0 -
v21.0.0 -
v20.18.0 iron
v20.17.0 iron
v20.16.0 iron
v20.15.1 iron
v20.15.0 iron
v20.14.0 iron
v20.13.1 iron
v20.13.0 iron
v20.12.2 iron
v20.12.1 iron
v20.12.0 iron
v20.11.1 iron
v20.11.0 iron
v20.10.0 iron
v20.9.0 iron
v20.8.1 -
v20.8.0 -
v20.7.0 -
v20.6.1 -
v20.6.0 -
v20.5.1 -
v20.5.0 -
v20.4.0 -
v20.3.1 -
v20.3.0 -
v20.2.0 -
v20.1.0 -
v20.0.0 -
v19.9.0 -
v19.8.1 -
v19.8.0 -
v19.7.0 -
v19.6.1 -
v19.6.0 -
v19.5.0 -
v19.4.0 -
v19.3.0 -
v19.2.0 -
v19.1.0 -
v19.0.1 -
v19.0.0 -
v18.20.4 hydrogen
v18.20.3 hydrogen
v18.20.2 hydrogen
v18.20.1 hydrogen
v18.20.0 hydrogen
v18.19.1 hydrogen
v18.19.0 hydrogen
v18.18.2 hydrogen
v18.18.1 hydrogen
v18.18.0 hydrogen
v18.17.1 hydrogen
v18.17.0 hydrogen
v18.16.1 hydrogen
v18.16.0 hydrogen
v18.15.0 hydrogen
v18.14.2 hydrogen
v18.14.1 hydrogen
v18.14.0 hydrogen
v18.13.0 hydrogen
v18.12.1 hydrogen
v18.12.0 hydrogen
v18.11.0 -
v18.10.0 -
v18.9.1 -
v18.9.0 -
v18.8.0 -
v18.7.0 -
v18.6.0 -
v18.5.0 -
v18.4.0 -
v18.3.0 -
v18.2.0 -
v18.1.0 -
v18.0.0 -
v17.9.1 -
v17.9.0 -
v17.8.0 -
v17.7.2 -
v17.7.1 -
v17.7.0 -
v17.6.0 -
v17.5.0 -
v17.4.0 -
v17.3.1 -
v17.3.0 -
v17.2.0 -
v17.1.0 -
v17.0.1 -
v17.0.0 -
v16.20.2 gallium
v16.20.1 gallium
v16.20.0 gallium
v16.19.1 gallium
v16.19.0 gallium
v16.18.1 gallium
v16.18.0 gallium
v16.17.1 gallium
v16.17.0 gallium
v16.16.0 gallium
v16.15.1 gallium
v16.15.0 gallium
v16.14.2 gallium
v16.14.1 gallium
v16.14.0 gallium
v16.13.2 gallium
v16.13.1 gallium
v16.13.0 gallium
v16.12.0 -
v16.11.1 -
v16.11.0 -
v16.10.0 -
v16.9.1 -
v16.9.0 -
v16.8.0 -
v16.7.0 -
v16.6.2 -
v16.6.1 -
v16.6.0 -
v16.5.0 -
v16.4.2 -
v16.4.1 -
v16.4.0 -
v16.3.0 -
v16.2.0 -
v16.1.0 -
v16.0.0 -
v15.14.0 -
v15.13.0 -
v15.12.0 -
v15.11.0 -
v15.10.0 -
v15.9.0 -
v15.8.0 -
v15.7.0 -
v15.6.0 -
v15.5.1 -
v15.5.0 -
v15.4.0 -
v15.3.0 -
v15.2.1 -
v15.2.0 -
v15.1.0 -
v15.0.1 -
v15.0.0 -
v14.21.3 fermium
v14.21.2 fermium
v14.21.1 fermium
v14.21.0 fermium
v14.20.1 fermium
v14.20.0 fermium
v14.19.3 fermium
v14.19.2 fermium
v14.19.1 fermium
v14.19.0 fermium
v14.18.3 fermium
v14.18.2 fermium
v14.18.1 fermium
v14.18.0 fermium
v14.17.6 fermium
v14.17.5 fermium
v14.17.4 fermium
v14.17.3 fermium
v14.17.2 fermium
v14.17.1 fermium
v14.17.0 fermium
v14.16.1 fermium
v14.16.0 fermium
v14.15.5 fermium
v14.15.4 fermium
v14.15.3 fermium
v14.15.2 fermium
v14.15.1 fermium
v14.15.0 fermium
v14.14.0 -
v14.13.1 -
v14.13.0 -
v14.12.0 -
v14.11.0 -
v14.10.1 -
v14.10.0 -
v14.9.0 -
v14.8.0 -
v14.7.0 -
v14.6.0 -
v14.5.0 -
v14.4.0 -
v14.3.0 -
v14.2.0 -
v14.1.0 -
v14.0.0 -
v13.14.0 -
v13.13.0 -
v13.12.0 -
v13.11.0 -
v13.10.1 -
v13.10.0 -
v13.9.0 -
v13.8.0 -
v13.7.0 -
v13.6.0 -
v13.5.0 -
v13.4.0 -
v13.3.0 -
v13.2.0 -
v13.1.0 -
v13.0.1 -
v13.0.0 -
v12.22.12 erbium
v12.22.11 erbium
v12.22.10 erbium
v12.22.9 erbium
v12.22.8 erbium
v12.22.7 erbium
v12.22.6 erbium
v12.22.5 erbium
v12.22.4 erbium
v12.22.3 erbium
v12.22.2 erbium
v12.22.1 erbium
v12.22.0 erbium
v12.21.0 erbium
v12.20.2 erbium
v12.20.1 erbium
v12.20.0 erbium
v12.19.1 erbium
v12.19.0 erbium
v12.18.4 erbium
v12.18.3 erbium
v12.18.2 erbium
v12.18.1 erbium
v12.18.0 erbium
v12.17.0 erbium
v12.16.3 erbium
v12.16.2 erbium
v12.16.1 erbium
v12.16.0 erbium
v12.15.0 erbium
v12.14.1 erbium
v12.14.0 erbium
v12.13.1 erbium
v12.13.0 erbium
v12.12.0 -
v12.11.1 -
v12.11.0 -
v12.10.0 -
v12.9.1 -
v12.9.0 -
v12.8.1 -
v12.8.0 -
v12.7.0 -
v12.6.0 -
v12.5.0 -
v12.4.0 -
v12.3.1 -
v12.3.0 -
v12.2.0 -
v12.1.0 -
v12.0.0 -
v11.15.0 -
v11.14.0 -
v11.13.0 -
v11.12.0 -
v11.11.0 -
v11.10.1 -
v11.10.0 -
v11.9.0 -
v11.8.0 -
v11.7.0 -
v11.6.0 -
v11.5.0 -
v11.4.0 -
v11.3.0 -
v11.2.0 -
v11.1.0 -
v11.0.0 -
v10.24.1 dubnium
v10.24.0 dubnium
v10.23.3 dubnium
v10.23.2 dubnium
v10.23.1 dubnium
v10.23.0 dubnium
v10.22.1 dubnium
v10.22.0 dubnium
v10.21.0 dubnium
v10.20.1 dubnium
v10.20.0 dubnium
v10.19.0 dubnium
v10.18.1 dubnium
v10.18.0 dubnium
v10.17.0 dubnium
v10.16.3 dubnium
v10.16.2 dubnium
v10.16.1 dubnium
v10.16.0 dubnium
v10.15.3 dubnium
v10.15.2 dubnium
v10.15.1 dubnium
v10.15.0 dubnium
v10.14.2 dubnium
v10.14.1 dubnium
v10.14.0 dubnium
v10.13.0 dubnium
v10.12.0 -
v10.11.0 -
v10.10.0 -
v10.9.0 -
v10.8.0 -
v10.7.0 -
v10.6.0 -
v10.5.0 -
v10.4.1 -
v10.4.0 -
v10.3.0 -
v10.2.1 -
v10.2.0 -
v10.1.0 -
v10.0.0 -
v9.11.2 -
v9.11.1 -
v9.11.0 -
v9.10.1 -
v9.10.0 -
v9.9.0 -
v9.8.0 -
v9.7.1 -
v9.7.0 -
v9.6.1 -
v9.6.0 -
v9.5.0 -
v9.4.0 -
v9.3.0 -
v9.2.1 -
v9.2.0 -
v9.1.0 -
v9.0.0 -
v8.17.0 carbon
v8.16.2 carbon
v8.16.1 carbon
v8.16.0 carbon
v8.15.1 carbon
v8.15.0 carbon
v8.14.1 carbon
v8.14.0 carbon
v8.13.0 carbon
v8.12.0 carbon
v8.11.4 carbon
v8.11.3 carbon
v8.11.2 carbon
v8.11.1 carbon
v8.11.0 carbon
v8.10.0 carbon
v8.9.4 carbon
v8.9.3 carbon
v8.9.2 carbon
v8.9.1 carbon
v8.9.0 carbon
v8.8.1 -
v8.8.0 -
v8.7.0 -
v8.6.0 -
v8.5.0 -
v8.4.0 -
v8.3.0 -
v8.2.1 -
v8.2.0 -
v8.1.4 -
v8.1.3 -
v8.1.2 -
v8.1.1 -
v8.1.0 -
v8.0.0 -
v7.10.1 -
v7.10.0 -
v7.9.0 -
v7.8.0 -
v7.7.4 -
v7.7.3 -
v7.7.2 -
v7.7.1 -
v7.7.0 -
v7.6.0 -
v7.5.0 -
v7.4.0 -
v7.3.0 -
v7.2.1 -
v7.2.0 -
v7.1.0 -
v7.0.0 -
v6.17.1 boron
v6.17.0 boron
v6.16.0 boron
v6.15.1 boron
v6.15.0 boron
v6.14.4 boron
v6.14.3 boron
v6.14.2 boron
v6.14.1 boron
v6.14.0 boron
v6.13.1 boron
v6.13.0 boron
v6.12.3 boron
v6.12.2 boron
v6.12.1 boron
v6.12.0 boron
v6.11.5 boron
v6.11.4 boron
v6.11.3 boron
v6.11.2 boron
v6.11.1 boron
v6.11.0 boron
v6.10.3 boron
v6.10.2 boron
v6.10.1 boron
v6.10.0 boron
v6.9.5 boron
v6.9.4 boron
v6.9.3 boron
v6.9.2 boron
v6.9.1 boron
v6.9.0 boron
v6.8.1 -
v6.8.0 -
v6.7.0 -
v6.6.0 -
v6.5.0 -
v6.4.0 -
v6.3.1 -
v6.3.0 -
v6.2.2 -
v6.2.1 -
v6.2.0 -
v6.1.0 -
v6.0.0 -
v5.12.0 -
v5.11.1 -
v5.11.0 -
v5.10.1 -
v5.10.0 -
v5.9.1 -
v5.9.0 -
v5.8.0 -
v5.7.1 -
v5.7.0 -
v5.6.0 -
v5.5.0 -
v5.4.1 -
v5.4.0 -
v5.3.0 -
v5.2.0 -
v5.1.1 -
v5.1.0 -
v5.0.0 -
v4.9.1 argon
v4.9.0 argon
v4.8.7 argon
v4.8.6 argon
v4.8.5 argon
v4.8.4 argon
v4.8.3 argon
v4.8.2 argon
v4.8.1 argon
v4.8.0 argon
v4.7.3 argon
v4.7.2 argon
v4.7.1 argon
v4.7.0 argon
v4.6.2 argon
v4.6.1 argon
v4.6.0 argon
v4.5.0 argon
v4.4.7 argon
v4.4.6 argon
v4.4.5 argon
v4.4.4 argon
v4.4.3 argon
v4.4.2 argon
v4.4.1 argon
v4.4.0 argon
v4.3.2 argon
v4.3.1 argon
v4.3.0 argon
v4.2.6 argon
v4.2.5 argon
v4.2.4 argon
v4.2.3 argon
v4.2.2 argon
v4.2.1 argon
v4.2.0 argon
v4.1.2 -
v4.1.1 -
v4.1.0 -
v4.0.0 -
v0.12.18 -
v0.12.17 -
v0.12.16 -
v0.12.15 -
v0.12.14 -
v0.12.13 -
v0.12.12 -
v0.12.11 -
v0.12.10 -
v0.12.9 -
v0.12.8 -
v0.12.7 -
v0.12.6 -
v0.12.5 -
v0.12.4 -
v0.12.3 -
v0.12.2 -
v0.12.1 -
v0.12.0 -
v0.11.16 -
v0.11.15 -
v0.11.14 -
v0.11.13 -
v0.11.12 -
v0.11.11 -
v0.11.10 -
v0.11.9 -
v0.11.8 -
v0.11.7 -
v0.11.6 -
v0.11.5 -
v0.11.4 -
v0.11.3 -
v0.11.2 -
v0.11.1 -
v0.11.0 -
v0.10.48 -
v0.10.47 -
v0.10.46 -
v0.10.45 -
v0.10.44 -
v0.10.43 -
v0.10.42 -
v0.10.41 -
v0.10.40 -
v0.10.39 -
v0.10.38 -
v0.10.37 -
v0.10.36 -
v0.10.35 -
v0.10.34 -
v0.10.33 -
v0.10.32 -
v0.10.31 -
v0.10.30 -
v0.10.29 -
v0.10.28 -
v0.10.27 -
v0.10.26 -
v0.10.25 -
v0.10.24 -
v0.10.23 -
v0.10.22 -
v0.10.21 -
v0.10.20 -
v0.10.19 -
v0.10.18 -
v0.10.17 -
v0.10.16 -
v0.10.15 -
v0.10.14 -
v0.10.13 -
v0.10.12 -
v0.10.11 -
v0.10.10 -
v0.10.9 -
v0.10.8 -
v0.10.7 -
v0.10.6 -
v0.10.5 -
v0.10.4 -
v0.10.3 -
v0.10.2 -
v0.10.1 -
v0.10.0 -
v0.9.12 -
v0.9.11 -
v0.9.10 -
v0.9.9 -
v0.9.8 -
v0.9.7 -
v0.9.6 -
v0.9.5 -
v0.9.4 -
v0.9.3 -
v0.9.2 -
v0.9.1 -
v0.9.0 -
v0.8.28 -
v0.8.27 -
v0.8.26 -
v0.8.25 -
v0.8.24 -
v0.8.23 -
v0.8.22 -
v0.8.21 -
v0.8.20 -
v0.8.19 -
v0.8.18 -
v0.8.17 -
v0.8.16 -
v0.8.15 -
v0.8.14 -
v0.8.13 -
v0.8.12 -
v0.8.11 -
v0.8.10 -
v0.8.9 -
v0.8.8 -
v0.8.7 -
v0.8.6 -
v0.8.5 -
v0.8.4 -
v0.8.3 -
v0.8.2 -
v0.8.1 -
v0.8.0 -
v0.7.12 -
v0.7.11 -
v0.7.10 -
v0.7.9 -
v0.7.8 -
v0.7.7 -
v0.7.6 -
v0.7.5 -
v0.7.4 -
v0.7.3 -
v0.7.2 -
v0.7.1 -
v0.7.0 -
v0.6.21 -
v0.6.20 -
v0.6.19 -
v0.6.18 -
v0.6.17 -
v0.6.16 -
v0.6.15 -
v0.6.14 -
v0.6.13 -
v0.6.12 -
v0.6.11 -
v0.6.10 -
v0.6.9 -
v0.6.8 -
v0.6.7 -
v0.6.6 -
v0.6.5 -
v0.6.4 -
v0.6.3 -
v0.6.2 -
v0.6.1 -
v0.6.0 -
v0.5.10 -
v0.5.9 -
v0.5.8 -
v0.5.7 -
v0.5.6 -
v0.5.5 -
v0.5.4 -
v0.5.3 -
v0.5.2 -
v0.5.1 -
v0.5.0 -
v0.4.12 -
v0.4.11 -
v0.4.10 -
v0.4.9 -
v0.4.8 -
v0.4.7 -
v0.4.6 -
v0.4.5 -
v0.4.4 -
v0.4.3 -
v0.4.2 -
v0.4.1 -
v0.4.0 -
v0.3.8 -
v0.3.7 -
v0.3.6 -
v0.3.5 -
v0.3.4 -
v0.3.3 -
v0.3.2 -
v0.3.1 -
v0.3.0 -
v0.2.6 -
v0.2.5 -
v0.2.4 -
v0.2.3 -
v0.2.2 -
v0.2.1 -
v0.2.0 -
v0.1.104 -
v0.1.103 -
v0.1.102 -
v0.1.101 -
v0.1.100 -
v0.1.99 -
v0.1.98 -
v0.1.97 -
v0.1.96 -
v0.1.95 -
v0.1.94 -
v0.1.93 -
v0.1.92 -
v0.1.91 -
v0.1.90 -
v0.1.33 -
v0.1.32 -
v0.1.31 -
v0.1.30 -
v0.1.29 -
v0.1.28 -
v0.1.27 -
v0.1.26 -
v0.1.25 -
v0.1.24 -
v0.1.23 -
v0.1.22 -
v0.1.21 -
v0.1.20 -
v0.1.19 -
v0.1.18 -
v0.1.17 -
v0.1.16 -
v0.1.15 -
v0.1.14 -
+3
View File
@@ -19,6 +19,9 @@ if [ -n "${NVM_COLORS-}" ]; then
unset NVM_COLORS
fi
# these mocks must not be recorded as the LTS status of $NVM_DIR's versions
nvm_record_lts_status() { :; }
MOCKS_DIR="../Unit tests/mocks"
LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
+3
View File
@@ -9,6 +9,9 @@ cleanup() {
: nvm.sh
\. ../../../nvm.sh
# these mocks must not be recorded as the LTS status of $NVM_DIR's versions
nvm_record_lts_status() { :; }
MOCKS_DIR="$PWD/mocks"
# sample output at the time the test was written
@@ -19,6 +19,9 @@ cleanup() {
set -ex
# these mocks must not be recorded as the LTS status of $NVM_DIR's versions
nvm_record_lts_status() { :; }
MOCKS_DIR="$PWD/mocks"
# sample output at the time the test was written
+83
View File
@@ -0,0 +1,83 @@
#!/bin/sh
ORIG_NVM_DIR="${NVM_DIR}"
TMP_DIR=''
cleanup () {
case "${TMP_DIR}" in
/*) rm -rf "${TMP_DIR}" ;;
esac
NVM_DIR="${ORIG_NVM_DIR}"
export NVM_DIR
unset -f nvm_download
}
die () { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
TMP_DIR="$(mktemp -d)"
NVM_DIR="${TMP_DIR}/nvm"
export NVM_DIR
mkdir -p "${NVM_DIR}" || die 'could not create NVM_DIR'
row () {
printf '%s\t2024-01-01\tsrc\t-\t-\t-\t-\t-\t-\t%s\t-\n' "$1" "$2"
}
DOWNLOADS="${TMP_DIR}/downloads"
nvm_download () {
echo "$*" >> "${DOWNLOADS}"
case "$*" in
*index.tab*)
printf 'version\tdate\tfiles\tnpm\tv8\tuv\tzlib\topenssl\tmodules\tlts\tsecurity\n'
row v24.11.0 Krypton
row v24.0.0 -
;;
*) return 1 ;;
esac
}
recorded () {
[ -f "$(nvm_lts_status_path)" ] || die "no LTS status is recorded, so $1 has none"
OUTPUT="$(command awk -v version="$1" '$1 == version { lts = $2 } END { print (lts == "" ? "-" : lts) }' "$(nvm_lts_status_path)")"
[ "_${OUTPUT}" = "_$2" ] || die "the recorded LTS status of $1 is >${OUTPUT}<, expected >$2<"
}
# an index without any LTS versions, like a nightly one, cannot start the record
{ row v27.0.0-nightly20261020abc -; row v26.0.0-rc.1 -; } | nvm_record_lts_status
[ $? = 1 ] || die 'nvm_record_lts_status should not start a record from an index without LTS versions'
[ ! -f "$(nvm_lts_status_path)" ] || die 'no LTS status should have been recorded'
(NVM_OFFLINE=1 nvm_ensure_lts_status)
[ $? = 3 ] || die 'nvm_ensure_lts_status should not download while offline'
[ ! -f "${DOWNLOADS}" ] || die "nothing should have been downloaded while offline; got $(cat "${DOWNLOADS}")"
nvm_ensure_lts_status || die 'nvm_ensure_lts_status should download and record LTS status'
recorded v24.11.0 krypton
recorded v24.0.0 -
nvm_ensure_lts_status || die 'nvm_ensure_lts_status should succeed once LTS status is recorded'
[ "$(wc -l < "${DOWNLOADS}" | tr -d ' ')" = 1 ] || die "LTS status should be downloaded only once; got $(cat "${DOWNLOADS}")"
# later downloads merge, even without any LTS versions
row v27.0.0-nightly20261020abc - | nvm_record_lts_status || die 'nvm_record_lts_status should merge into an existing record'
{ row v26.0.0 -; row v24.0.0 Krypton; } | nvm_record_lts_status || die 'nvm_record_lts_status should record index rows'
recorded v27.0.0-nightly20261020abc -
recorded v26.0.0 -
recorded v24.0.0 krypton
recorded v24.11.0 krypton
# a real index records what `update_test_mocks.sh` recorded from it
MOCKS_DIR="$PWD/mocks"
(
NVM_DIR="${TMP_DIR}/mock"
mkdir -p "${NVM_DIR}" || die 'could not create a second NVM_DIR'
sed 1d "${MOCKS_DIR}/nodejs.org-dist-index.tab" | nvm_record_lts_status || die 'nvm_record_lts_status should record the index mock'
cmp -s "$(nvm_lts_status_path)" "${MOCKS_DIR}/nodejs.org-dist-lts-status.txt" || die 'recording the index mock should match nodejs.org-dist-lts-status.txt'
) || exit 1
printf '<html>\n<body>v24.11.0 Not Found</body>\n</html>\n' | nvm_record_lts_status
[ $? = 1 ] || die 'nvm_record_lts_status should reject content without index rows'
recorded v24.11.0 krypton
cleanup
+9
View File
@@ -53,6 +53,15 @@ NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ NVM_LTS=* nvm_ls_remo
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ NVM_LTS=argon nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote LTS nightly argon.txt"
set -e
# the LTS status that `nodejs.org-dist-index.tab` records, written to the mock instead of `$NVM_DIR`
(
nvm_lts_status_path() {
nvm_echo "$MOCKS_DIR/nodejs.org-dist-lts-status.txt"
}
command rm -f "$(nvm_lts_status_path)"
command sed 1d "$MOCKS_DIR/nodejs.org-dist-index.tab" | nvm_record_lts_status
)
ALIAS_PATH="$MOCKS_DIR/nvm_make_alias LTS alias calls.txt"
: > "$ALIAS_PATH"
LTS_NAMES_PATH="$MOCKS_DIR/LTS_names.txt"