[New] `nvm ls-remote`: annotate versions with the `node` alias and local aliases
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Fixes #2786. Ben Younes added the alias annotations to bare `nvm ls-remote`, with their regression tests; Jordan Harband moved `(Latest: node)` onto the newest node release, gave each kind of annotation a fixed column so the output can be sliced with `cut`, matched aliases to versions in one pass, and kept local aliases out of the mocks and tests.
authored by Ben Younes · committed by Jordan Harband · parent 04fbd95 · Browse files · 6 files·+326 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Ben Younes <2910651+ousamabenyounes@users.noreply.github.com>
- Co-authored-by: Jordan Harband <ljharb@gmail.com>
Diff stats
6 files+326 added−14 removed
- tests:+131 added−2 removed
- other:+195 added−12 removed
Provenance
- Commit
a8bb497- Tree
3256c1c- Author
Ben Younes <2910651+ousamabenyounes@users.noreply.github.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
04fbd95
6 files changed+326 added−14 removed
modified:test/fast/Unit tests/mocks/nvm ls-remote.txt+1 added-1 removed
795 unmodified lines796 v22.9.0797 v22.10.0798 v22.11.0 [1;32m (Latest LTS: Jod)[0m799 v23.0.0800- v23.1.0800+ v23.1.0 [0;32m (Latest: [3mnode[23m)[0mmodified:test/fast/Unit tests/nvm ls-remote+4 added-1 removed
1 unmodified line2 3 die () { echo "$@" ; cleanup ; exit 1; }4 5 cleanup() {6- unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs6+ unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs nvm_get_remote_aliases nvm_has_italics7 if [ -n "${TEMP_NVM_COLORS-}" ]; then8 export NVM_COLORS=TEMP_NVM_COLORS9 fi10 unset TEMP_NVM_COLORS75 unmodified lines86 REMOTE_IOJS="${PWD}/mocks/nvm_ls_remote_iojs.txt"87 nvm_ls_remote_iojs() {88 cat "${REMOTE_IOJS}"89 }90+# the mock must not depend on whatever local aliases exist in $NVM_DIR91+nvm_get_remote_aliases() { :; }92+nvm_has_italics() { return 0; }93 94 EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"95 OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"96 EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"3 unmodified linesadded:test/fast/Unit tests/nvm ls-remote aliases+126 added
1+#!/bin/sh2+3+WORK="${PWD}/nvm-ls-remote-aliases-work.$$"4+export HOME="${WORK}/home"5+export NVM_DIR="${HOME}/.nvm"6+7+cleanup() {8+ command rm -rf "${WORK}"9+ unset -f cleanup die nvm_has_colors nvm_has_italics nvm_remote_versions expected_row10+}11+die () { echo "$@" ; cleanup ; exit 1; }12+13+command mkdir -p "${NVM_DIR}/alias/lts" "${NVM_DIR}/versions/node/v1.5.0"14+15+: nvm.sh16+\. ../../../nvm.sh17+18+nvm_has_colors() { return 1; }19+nvm_remote_versions() {20+ if [ -n "${NVM_LTS-}" ] || [ -n "${1-}" ]; then21+ command printf '%s\n' 'v2.0.0'22+ else23+ # io.js sorts last here, so the latest node release is not the last row24+ command printf '%s\n' 'v0.11.16' 'v0.12.18' 'v1.0.0 Argon' 'v1.5.0' 'v2.0.0 Iron *' 'iojs-v3.3.1'25+ fi26+ return "${NVM_REMOTE_STATUS-0}"27+}28+29+nvm_make_alias 'project' '1' >/dev/null30+nvm_make_alias 'argon-project' '1.0' >/dev/null31+nvm_make_alias 'lts/iron' 'v2.0.0' >/dev/null32+nvm_make_alias 'iron-project' 'lts/iron' >/dev/null33+nvm_make_alias 'latest-project' 'node' >/dev/null34+nvm_make_alias 'stable-project' 'stable' >/dev/null35+nvm_make_alias 'unstable-project' 'unstable' >/dev/null36+nvm_make_alias 'io-project' 'iojs' >/dev/null37+nvm_make_alias '.hidden-project' '1' >/dev/null38+command printf '%s\n' '[' > "${NVM_DIR}/alias/invalid-pattern"39+command printf '%s\n' '1' > "${NVM_DIR}/alias/$(command printf 'control\rname')"40+41+# the version cell is 17 wide (`%15s` plus the ` *` installed marker or two spaces), then LTS, Latest, and Aliases columns42+expected_row() {43+ command printf '%-17s%-19s %-15s %s\n' "$1" "$2" "$3" "$4" | command sed 's/[[:space:]]*$//'44+}45+EXPECTED_OUTPUT="$(46+ expected_row ' v0.11.16' '' '' ' (Aliases: unstable-project)'47+ expected_row ' v0.12.18'48+ expected_row ' v1.0.0' ' (LTS: Argon)' '' ' (Aliases: argon-project)'49+ expected_row ' v1.5.0 *' '' '' ' (Aliases: project)'50+ expected_row ' v2.0.0' ' (Latest LTS: Iron)' ' (Latest: node)' ' (Aliases: iron-project, latest-project, stable-project)'51+ expected_row ' iojs-v3.3.1' '' '' ' (Aliases: io-project)'52+)"53+54+REMOTE_ERROR="${WORK}/remote-error"55+OUTPUT="$(NVM_REMOTE_LATEST_ALIAS='injected' NVM_REMOTE_NAMED_ALIASES="$(command printf 'v0.12.18\tinjected')" nvm ls-remote --no-colors 2>"${REMOTE_ERROR}")"56+57+[ ! -s "${REMOTE_ERROR}" ] \58+ || die "bare nvm ls-remote emitted an error; got >$(command cat "${REMOTE_ERROR}")<"59+[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \60+ || die "bare nvm ls-remote did not annotate aliases in stable columns; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"61+62+ALIASES_COLUMN="$(command printf '%s\n' "${OUTPUT}" | command cut -c56-65 | command sort -u)"63+[ "_${ALIASES_COLUMN}" = "_$(command printf '\n (Aliases:')" ] \64+ || die "bare nvm ls-remote did not start every Aliases annotation in the same column; got >${ALIASES_COLUMN}<"65+66+case "${OUTPUT}" in67+ *'node, stable'* | *unstable,* | *hidden* | *invalid* | *control* | *injected*)68+ die "bare nvm ls-remote showed an alias it should omit; got >${OUTPUT}<"69+ ;;70+esac71+72+EXPECTED_FILTERED_OUTPUT='v2.0.0'73+OUTPUT="$(nvm ls-remote 2 --no-colors | command sed 's/^[[:space:]]*//')"74+[ "_${OUTPUT}" = "_${EXPECTED_FILTERED_OUTPUT}" ] \75+ || die "filtered nvm ls-remote annotated aliases; got >${OUTPUT}< expected >${EXPECTED_FILTERED_OUTPUT}<"76+77+OUTPUT="$(nvm ls-remote --lts --no-colors | command sed 's/^[[:space:]]*//')"78+[ "_${OUTPUT}" = "_${EXPECTED_FILTERED_OUTPUT}" ] \79+ || die "LTS nvm ls-remote annotated aliases; got >${OUTPUT}< expected >${EXPECTED_FILTERED_OUTPUT}<"80+81+NVM_REMOTE_STATUS=182+OUTPUT="$(nvm ls-remote --no-colors 2>/dev/null)"83+COMMAND_STATUS=$?84+NVM_REMOTE_STATUS=085+[ "${COMMAND_STATUS}" -eq 1 ] \86+ || die "failed nvm ls-remote returned ${COMMAND_STATUS}; expected 1"87+case "${OUTPUT}" in88+ *Latest:* | *Aliases:*) die "failed nvm ls-remote annotated aliases; got >${OUTPUT}<" ;;89+esac90+91+nvm_has_colors() { return 0; }92+nvm_has_italics() { return 0; }93+94+ESC="$(command printf '\033')"95+OUTPUT="$(nvm ls-remote)"96+EXPECTED_LATEST_ROW="$(command printf ' v2.0.0 \033[1;32m (Latest LTS: Iron)\033[0m \033[0;32m (Latest: \033[3mnode\033[23m)\033[0m \033[0;32m (Aliases: \033[3miron-project\033[23m, \033[3mlatest-project\033[23m, \033[3mstable-project\033[23m)\033[0m')"97+case "${OUTPUT}" in98+ *"${EXPECTED_LATEST_ROW}"*) ;;99+ *) die "colored nvm ls-remote did not use an unbolded color and italic names for aliases; got >${OUTPUT}<" ;;100+esac101+102+nvm_has_italics() { return 1; }103+NO_ITALICS_OUTPUT="$(nvm ls-remote)"104+nvm_has_italics() { return 0; }105+EXPECTED_LATEST_ROW="$(command printf ' v2.0.0 \033[1;32m (Latest LTS: Iron)\033[0m \033[0;32m (Latest: node)\033[0m \033[0;32m (Aliases: iron-project, latest-project, stable-project)\033[0m')"106+case "${NO_ITALICS_OUTPUT}" in107+ *"${EXPECTED_LATEST_ROW}"*) ;;108+ *) die "colored nvm ls-remote used italics on a terminal without italics support; got >${NO_ITALICS_OUTPUT}<" ;;109+esac110+111+OUTPUT="$(command printf '%s\n' "${OUTPUT}" | command sed "s/${ESC}\[[0-9;]*m//g")"112+EXPECTED_OUTPUT="$(command printf '%s\n' "${EXPECTED_OUTPUT}" | command sed 's/^\( v1\.5\.0\) \*/\1 /')"113+[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \114+ || die "colored nvm ls-remote did not keep annotation columns aligned; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"115+116+nvm_has_colors() { return 1; }117+nvm_remote_versions() {118+ command printf '%s\n' 'v2.0.0-nightly20240101abcdef0123 Iron *' 'v3.0.0-nightly2024020201234567890abc'119+}120+nvm_make_alias 'nightly-project' 'v2.0.0-nightly20240101abcdef0123' >/dev/null121+OUTPUT="$(nvm ls-remote --no-colors)"122+ALIASES_COLUMNS="$(command printf '%s\n' "${OUTPUT}" | command awk 'index($0, "(Aliases:") { print index($0, "(Aliases:") }' | command sort -u)"123+[ "$(command printf '%s\n' "${ALIASES_COLUMNS}" | command wc -l | command tr -d ' ')" = 1 ] \124+ || die "versions wider than the version column did not keep Aliases annotations in one column; got >${OUTPUT}<"125+126+cleanupmodified:nvm.sh+176 added-12 removed
2159 unmodified lines2160 2161 nvm_download -L -s "${SHASUMS_URL}" -o - | command awk -v tarball="${4}.${5}" '{ if (tarball == $2) print $1 }'2162 }2163 2164+nvm_get_remote_aliases() {2165+ local NVM_ALIAS_DIR2166+ NVM_ALIAS_DIR="$(nvm_alias_path)"2167+ if [ ! -d "${NVM_ALIAS_DIR}" ]; then2168+ return 02169+ fi2170+2171+ local NVM_NODE_PREFIX2172+ NVM_NODE_PREFIX="$(nvm_node_prefix)"2173+ local NVM_IOJS_PREFIX2174+ NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"2175+ local NVM_ALIAS_PATH2176+ local NVM_ALIAS_NAME2177+ local NVM_ALIAS_TARGET2178+2179+ nvm_is_zsh && setopt local_options nonomatch2180+ # the same glob as `nvm_list_aliases`, so this never shows an alias that `nvm alias` omits2181+ for NVM_ALIAS_PATH in "${NVM_ALIAS_DIR}/"*; do2182+ if [ ! -f "${NVM_ALIAS_PATH}" ]; then2183+ continue2184+ fi2185+2186+ NVM_ALIAS_NAME="${NVM_ALIAS_PATH##*/}"2187+ case "${NVM_ALIAS_NAME}" in2188+ "${NVM_NODE_PREFIX}" | "${NVM_IOJS_PREFIX}" | stable | unstable) continue ;;2189+ # control characters would corrupt the terminal, or the tab-separated output2190+ *[[:cntrl:]]*) continue ;;2191+ esac2192+2193+ NVM_ALIAS_TARGET="$(nvm_resolve_alias "${NVM_ALIAS_NAME}" 2>/dev/null)" || continue2194+ case "${NVM_ALIAS_TARGET}" in2195+ '' | *[[:cntrl:]]*) continue ;;2196+ esac2197+2198+ command printf '%s\t%s\n' "${NVM_ALIAS_TARGET}" "${NVM_ALIAS_NAME}"2199+ done2200+}2201+2202 nvm_print_versions() {2203 local NVM_CURRENT2204 NVM_CURRENT=$(nvm_ls_current)2205 2206+ local NVM_LATEST_ALIAS2207+ NVM_LATEST_ALIAS="${2-}"2208+ local NVM_NAMED_ALIASES2209+ NVM_NAMED_ALIASES="${3-}"2210+2211 local INSTALLED_COLOR2212 local SYSTEM_COLOR2213 local CURRENT_COLOR2214 local NOT_INSTALLED_COLOR12 unmodified lines2227 if nvm_has_colors; then2228 NVM_HAS_COLORS=12229 fi2230 2231+ local NVM_HAS_ITALICS2232+ NVM_HAS_ITALICS=02233+ if [ "${NVM_HAS_COLORS}" = 1 ] && [ -n "${NVM_LATEST_ALIAS}${NVM_NAMED_ALIASES}" ] && nvm_has_italics; then2234+ NVM_HAS_ITALICS=12235+ fi2236+2237+ NVM_NAMED_ALIASES="${NVM_NAMED_ALIASES}" \2238 command awk \2239 -v remote_versions="$(printf '%s' "${1-}" | tr '\n' '|')" \2240+ -v latest_alias="${NVM_LATEST_ALIAS}" \2241+ -v node_prefix="$(nvm_node_prefix)" -v iojs_prefix="$(nvm_iojs_prefix)" \2242 -v installed_versions="$(nvm_ls | tr '\n' '|')" -v current="$NVM_CURRENT" \2243 -v installed_color="$INSTALLED_COLOR" -v system_color="$SYSTEM_COLOR" \2244 -v current_color="$CURRENT_COLOR" -v default_color="$DEFAULT_COLOR" \2193- -v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '2245+ -v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" \2246+ -v has_italics="$NVM_HAS_ITALICS" '2247 function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }2248+function paint(color, text) { return (has_colors && color) ? ("\033[" color text "\033[0m") : text; }2249+function spaces(count, result) { result = ""; while (count-- > 0) result = result " "; return result; }2250+function italicize(text) { return has_italics ? ("\033[3m" text "\033[23m") : text; }2251 BEGIN {2252+ named_alias_list = ENVIRON["NVM_NAMED_ALIASES"];2253 fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";2254 fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";2255 fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";2256 2257 latest_lts_color = current_color;2258 sub(/0;/, "1;", latest_lts_color);2259+ alias_color = current_color;2260+ sub(/^1;/, "0;", alias_color);2261 2262 fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";2263 fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";2264 fmt_system_target = has_colors && system_color ? (" (\033[" system_color "-> %s\033[0m)") : " (-> %s)";3 unmodified lines2268 rows = alen(lines);2269 2270 for (n = 1; n <= rows; n++) {2271 split(lines[n], fields, "[[:blank:]]+");2272+ if (index(fields[1], iojs_prefix "-") == 1) {2273+ latest_iojs = fields[1];2274+ } else if (fields[1] ~ /^v0\.[0-9]*[13579]\./) {2275+ latest_unstable = fields[1];2276+ } else if (fields[1] ~ /^v[0-9]/) {2277+ latest_stable = fields[1];2278+ }2279+ }2280+2281+ named_alias_rows = split(named_alias_list, named_alias_lines, "\n");2282+ for (a = 1; a <= named_alias_rows; a++) {2283+ tab_position = index(named_alias_lines[a], "\t");2284+ if (tab_position < 2) {2285+ continue;2286+ }2287+ alias_target = substr(named_alias_lines[a], 1, tab_position - 1);2288+ alias_name = substr(named_alias_lines[a], tab_position + 1);2289+ if (alias_name == "") {2290+ continue;2291+ }2292+2293+ alias_version = "";2294+ if (alias_target == node_prefix || alias_target == "stable") {2295+ alias_version = latest_stable;2296+ } else if (alias_target == "unstable") {2297+ alias_version = latest_unstable;2298+ } else if (alias_target == iojs_prefix || alias_target == (iojs_prefix "-")) {2299+ alias_version = latest_iojs;2300+ } else {2301+ for (n = 1; n <= rows; n++) {2302+ split(lines[n], fields, "[[:blank:]]+");2303+ if (fields[1] == alias_target || index(fields[1], alias_target ".") == 1) {2304+ alias_version = fields[1];2305+ }2306+ }2307+ }2308+2309+ if (alias_version != "") {2310+ # mawk creates the assigned element before evaluating the right side, so `in` must be checked first2311+ if (alias_version in named_aliases) {2312+ named_aliases[alias_version] = named_aliases[alias_version] ", " alias_name;2313+ italic_aliases[alias_version] = italic_aliases[alias_version] ", " italicize(alias_name);2314+ } else {2315+ named_aliases[alias_version] = alias_name;2316+ italic_aliases[alias_version] = italicize(alias_name);2317+ }2318+ }2319+ }2320+2321+ for (n = 1; n <= rows; n++) {2322+ split(lines[n], fields, "[[:blank:]]+");2323 cols = alen(fields);2324 version = fields[1];2325 is_installed = 0;2326 12 unmodified lines2339 } else if (is_installed) {2340 fmt_version = fmt_installed;2341 }2342 2233- padding = (!has_colors && is_installed) ? "" : " ";2343+ padding[n] = (!has_colors && is_installed) ? "" : " ";2344 2235- if (cols == 1) {2236- formatted = sprintf(fmt_version, version);2237- } else if (version == "system" && cols >= 2) {2238- formatted = sprintf((fmt_version fmt_system_target), version, fields[2]);2345+ output[n] = sprintf(fmt_version, version);2346+ version_width[n] = output[n] padding[n];2347+ gsub(/\033\[[0-9;]*m/, "", version_width[n]);2348+ version_width[n] = length(version_width[n]);2349+ if (version_width[n] > max_version_width) {2350+ max_version_width = version_width[n];2351+ }2352+ for (c = 1; c <= 3; c++) {2353+ text[n, c] = "";2354+ cell[n, c] = "";2355+ }2356+ if (version == "system" && cols >= 2) {2357+ output[n] = output[n] sprintf(fmt_system_target, fields[2]);2358 } else if (cols == 2) {2240- formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);2359+ text[n, 1] = sprintf(" (LTS: %s)", fields[2]);2360+ cell[n, 1] = sprintf(fmt_old_lts, fields[2]);2361 } else if (cols == 3 && fields[3] == "*") {2242- formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);2362+ text[n, 1] = sprintf(" (Latest LTS: %s)", fields[2]);2363+ cell[n, 1] = sprintf(fmt_latest_lts, fields[2]);2364 }2365 2245- output[n] = formatted;2366+ if (latest_alias != "" && version == latest_stable) {2367+ text[n, 2] = " (Latest: " latest_alias ")";2368+ cell[n, 2] = paint(alias_color, " (Latest: " italicize(latest_alias) ")");2369+ }2370+2371+ if (version in named_aliases) {2372+ text[n, 3] = " (Aliases: " named_aliases[version] ")";2373+ cell[n, 3] = paint(alias_color, " (Aliases: " italic_aliases[version] ")");2374+ }2375+2376+ for (c = 1; c <= 3; c++) {2377+ if (length(text[n, c]) > width[c]) {2378+ width[c] = length(text[n, c]);2379+ }2380+ }2381 }2382 2383+ # each kind of annotation starts in the same column on every row, so the output stays `cut`-able2384 for (n = 1; n <= rows; n++) {2249- print output[n]2385+ last = 0;2386+ for (c = 1; c <= 3; c++) {2387+ if (text[n, c] != "") {2388+ last = c;2389+ }2390+ }2391+ formatted = output[n];2392+ if (last) {2393+ formatted = formatted padding[n];2394+ if (width[2] || width[3]) {2395+ formatted = formatted spaces(max_version_width - version_width[n]);2396+ }2397+ gap = "";2398+ for (c = 1; c <= last; c++) {2399+ if (width[c]) {2400+ formatted = formatted gap cell[n, c];2401+ gap = spaces(width[c] - length(text[n, c])) " ";2402+ }2403+ }2404+ }2405+ print formatted2406 }2407 2408 exit2409 }'2496 unmodified lines4906 local EXIT_CODE4907 NVM_OUTPUT="$(NVM_LTS="${NVM_LTS-}" nvm_remote_versions "${PATTERN-}" &&:)"4908 EXIT_CODE=$?4909 if [ -n "${NVM_OUTPUT}" ]; then4910+ local NVM_REMOTE_LATEST_ALIAS4911+ NVM_REMOTE_LATEST_ALIAS=''4912+ local NVM_REMOTE_NAMED_ALIASES4913+ NVM_REMOTE_NAMED_ALIASES=''4914+ if [ "${EXIT_CODE}" -eq 0 ] && [ -z "${NVM_LTS-}" ] && [ -z "${PATTERN-}" ]; then4915+ NVM_REMOTE_LATEST_ALIAS="$(nvm_node_prefix)"4916+ NVM_REMOTE_NAMED_ALIASES="$(nvm_get_remote_aliases)"4917+ fi4754- NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "${NVM_OUTPUT}"4918+ NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "${NVM_OUTPUT}" "${NVM_REMOTE_LATEST_ALIAS}" "${NVM_REMOTE_NAMED_ALIASES}"4919 return $EXIT_CODE4920 fi4921 NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "N/A"4922 return 3275 unmodified lines5198 unset -f nvm \5199 nvm_iojs_prefix nvm_node_prefix \5200 nvm_add_iojs_prefix nvm_strip_iojs_prefix \5201 nvm_is_iojs_version nvm_is_alias nvm_has_non_aliased \5038- nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \5202+ nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab nvm_get_remote_aliases \5203 nvm_ls nvm_remote_version nvm_remote_versions \5204 nvm_install_binary nvm_install_source nvm_clang_version \5205 nvm_get_mirror nvm_get_download_slug nvm_download_artifact \5206 nvm_install_npm_if_needed nvm_use_if_needed nvm_check_file_permissions \210 unmodified linesmodified:README.md+9 added
399 unmodified lines400 ```sh401 nvm ls-remote402 ```403 404+When no version or `--lts` filter is given, the list also marks the version the `node` alias would install, and every version that one of your own aliases would resolve to. Each kind of annotation always starts in the same column, so the output can be sliced with `cut -c` or similar tools:405+406+```407+ v20.9.0 (Latest LTS: Iron) (Aliases: work)408+ v21.0.0409+ v21.1.0410+ v21.2.0 (Latest: node) (Aliases: default)411+```412+413 And then in any new shell just use the installed version:414 415 ```sh416 nvm use node837 unmodified linesmodified:update_test_mocks.sh+10 added
18 unmodified lines19202122232425262728293031323334353633 unmodified lines18 unmodified lines # prevent local alias creation return 0}
nvm_get_remote_aliases() { # prevent local aliases from leaking into `nvm ls-remote` mocks return 0}
nvm_has_italics() { # keep mocks independent of the local terminal's italics support return 0}
nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote.txt"nvm_ls_remote_iojs > "$MOCKS_DIR/nvm_ls_remote_iojs.txt"NVM_LTS=* nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote LTS.txt"NVM_LTS=argon nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote LTS argon.txt"33 unmodified lines