Skip to content
Myr

[Fix] `nvm_alias`: ensure `lts/-1` returns the one before `lts/*`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #2461

authored by Rodrigo Espinosa de los Monteros · committed by Jordan Harband · parent 641f868 · Browse files · 2 files+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−3 removed

  • tests:+5 added−3 removed
  • other:+1 added−0 removed

2 files+6 added−3 removed

modified:test/fast/Unit tests/nvm_alias LTS-N+5 added-3 removed
23 unmodified lines
24LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"2526N=027while IFS= read -r LTS; do28 if [ $N -gt 0 ]; then29 EXPECTED="$(nvm_alias "lts/${LTS}")"30 ACTUAL="$(nvm_alias "lts/-${N}")"31 [ "${EXPECTED}" = "${ACTUAL}" ] || die "\`nvm_alias lts/-${N}\` was \`${ACTUAL}\`; expected \`${EXPECTED}\`"32 fi33 N=$(($N+1))29 EXPECTED="$(nvm_alias "lts/${LTS}")"30 ACTUAL="$(nvm_alias "lts/-${N}")"31 [ "${EXPECTED}" = "${ACTUAL}" ] || die "\`nvm_alias lts/-${N}\` was \`${ACTUAL}\`; expected \`${EXPECTED}\`"34done < "${LTS_NAMES_PATH}"3536cleanup
modified:nvm.sh+1 added
992 unmodified lines
993994 if [ "$(expr "${ALIAS}" : '^lts/-[1-9][0-9]*$')" -gt 0 ]; then995 local N996 N="$(echo "${ALIAS}" | cut -d '-' -f 2)"997 N=$((N+1))998 local RESULT999 RESULT="$(command ls "${NVM_ALIAS_DIR}/lts" | command tail -n "${N}" | command head -n 1)"1000 if [ "${RESULT}" != '*' ]; then1001 nvm_alias "lts/${RESULT}"
3186 unmodified lines