mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
[Fix] ls-remote
: do not match on bare LTS names, eg Argon
This commit is contained in:
parent
9f520c97db
commit
84bda8d402
14
nvm.sh
14
nvm.sh
@ -1688,10 +1688,15 @@ EOF
|
|||||||
LTS="${LTS#lts/}"
|
LTS="${LTS#lts/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
VERSIONS="$({ command awk -v lts="${LTS-}" -v pattern="${PATTERN:-.*}" '
|
||||||
if (!$1) { next }
|
BEGIN {
|
||||||
if (lts && $10 ~ /^\-?$/) { next }
|
if (pattern == "") pattern = ".*"
|
||||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
}
|
||||||
|
{
|
||||||
|
if (!$1) { next } # skip empty lines
|
||||||
|
if (lts && $10 ~ /^\-?$/) { next } # skip if LTS wanted, and row is not LTS
|
||||||
|
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next } # skip if LTS filter does not match
|
||||||
|
if ($1 !~ pattern) { next } # only keep rows matching the pattern
|
||||||
if ($10 !~ /^\-?$/) {
|
if ($10 !~ /^\-?$/) {
|
||||||
if ($10 && $10 != prev) {
|
if ($10 && $10 != prev) {
|
||||||
print $1, $10, "*"
|
print $1, $10, "*"
|
||||||
@ -1703,7 +1708,6 @@ EOF
|
|||||||
}
|
}
|
||||||
prev=$10;
|
prev=$10;
|
||||||
}' \
|
}' \
|
||||||
| nvm_grep -w "${PATTERN:-.*}" \
|
|
||||||
| $SORT_COMMAND; } << EOF
|
| $SORT_COMMAND; } << EOF
|
||||||
$VERSION_LIST
|
$VERSION_LIST
|
||||||
EOF
|
EOF
|
||||||
|
@ -83,4 +83,11 @@ EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
|||||||
OUTPUT="$(NVM_LTS=argon nvm_ls_remote)"
|
OUTPUT="$(NVM_LTS=argon nvm_ls_remote)"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS=argon nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS=argon nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls_remote Argon 2>&1)"
|
||||||
|
EXIT_CODE=$?
|
||||||
|
[ $EXIT_CODE -eq 3 ] || die "nvm_ls_remote Argon did not exit 3, got '${EXIT_CODE}'"
|
||||||
|
|
||||||
|
EXPECTED_OUTPUT='N/A'
|
||||||
|
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm_ls_remote Argon did not output expected error message; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user