[Fix] `nvm_alias`: ensure `lts/-1` returns the one before `lts/*`
Fixes #2461
parent
641f86879f
commit
4da7f101a2
1
nvm.sh
1
nvm.sh
|
@ -994,6 +994,7 @@ nvm_alias() {
|
||||||
if [ "$(expr "${ALIAS}" : '^lts/-[1-9][0-9]*$')" -gt 0 ]; then
|
if [ "$(expr "${ALIAS}" : '^lts/-[1-9][0-9]*$')" -gt 0 ]; then
|
||||||
local N
|
local N
|
||||||
N="$(echo "${ALIAS}" | cut -d '-' -f 2)"
|
N="$(echo "${ALIAS}" | cut -d '-' -f 2)"
|
||||||
|
N=$((N+1))
|
||||||
local RESULT
|
local RESULT
|
||||||
RESULT="$(command ls "${NVM_ALIAS_DIR}/lts" | command tail -n "${N}" | command head -n 1)"
|
RESULT="$(command ls "${NVM_ALIAS_DIR}/lts" | command tail -n "${N}" | command head -n 1)"
|
||||||
if [ "${RESULT}" != '*' ]; then
|
if [ "${RESULT}" != '*' ]; then
|
||||||
|
|
|
@ -25,10 +25,12 @@ LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
|
||||||
|
|
||||||
N=0
|
N=0
|
||||||
while IFS= read -r LTS; do
|
while IFS= read -r LTS; do
|
||||||
|
if [ $N -gt 0 ]; then
|
||||||
|
EXPECTED="$(nvm_alias "lts/${LTS}")"
|
||||||
|
ACTUAL="$(nvm_alias "lts/-${N}")"
|
||||||
|
[ "${EXPECTED}" = "${ACTUAL}" ] || die "\`nvm_alias lts/-${N}\` was \`${ACTUAL}\`; expected \`${EXPECTED}\`"
|
||||||
|
fi
|
||||||
N=$(($N+1))
|
N=$(($N+1))
|
||||||
EXPECTED="$(nvm_alias "lts/${LTS}")"
|
|
||||||
ACTUAL="$(nvm_alias "lts/-${N}")"
|
|
||||||
[ "${EXPECTED}" = "${ACTUAL}" ] || die "\`nvm_alias lts/-${N}\` was \`${ACTUAL}\`; expected \`${EXPECTED}\`"
|
|
||||||
done < "${LTS_NAMES_PATH}"
|
done < "${LTS_NAMES_PATH}"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
Loading…
Reference in New Issue