[Fix] `ls-remote`: fix issues in zsh when using a mirror with a ton of entries
Merge pull request #1818 from adedomin/master
commit
57ec311f53
18
nvm.sh
18
nvm.sh
|
@ -1107,7 +1107,13 @@ nvm_ls_remote() {
|
|||
local PATTERN
|
||||
PATTERN="${1-}"
|
||||
if nvm_validate_implicit_alias "${PATTERN}" 2> /dev/null ; then
|
||||
PATTERN="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "$(nvm_print_implicit_alias remote "${PATTERN}")" | command tail -1 | command awk '{ print $1 }')"
|
||||
local IMPLICIT
|
||||
IMPLICIT="$(nvm_print_implicit_alias remote "${PATTERN}")"
|
||||
if [ -z "${IMPLICIT-}" ] || [ "${IMPLICIT}" = 'N/A' ]; then
|
||||
nvm_echo "N/A"
|
||||
return 3
|
||||
fi
|
||||
PATTERN="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "${IMPLICIT}" | command tail -1 | command awk '{ print $1 }')"
|
||||
elif [ -n "${PATTERN}" ]; then
|
||||
PATTERN="$(nvm_ensure_version_prefix "${PATTERN}")"
|
||||
else
|
||||
|
@ -1212,8 +1218,7 @@ nvm_ls_remote_index_tab() {
|
|||
nvm_make_alias "$LTS_ALIAS" "$LTS_VERSION" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
VERSIONS="$(nvm_echo "${VERSION_LIST}" \
|
||||
| command awk -v pattern="${PATTERN-}" -v lts="${LTS-}" '{
|
||||
VERSIONS="$({ command awk -v pattern="${PATTERN-}" -v lts="${LTS-}" '{
|
||||
if (!$1) { next }
|
||||
if (pattern && tolower($1) !~ tolower(pattern)) { next }
|
||||
if (lts == "*" && $10 ~ /^\-?$/) { next }
|
||||
|
@ -1221,7 +1226,10 @@ nvm_ls_remote_index_tab() {
|
|||
if ($10 !~ /^\-?$/) print $1, $10; else print $1
|
||||
}' \
|
||||
| nvm_grep -w "${PATTERN:-.*}" \
|
||||
| $SORT_COMMAND)"
|
||||
| $SORT_COMMAND; } << EOF
|
||||
$VERSION_LIST
|
||||
EOF
|
||||
)"
|
||||
if [ "$ZSH_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
|
@ -1590,7 +1598,7 @@ nvm_print_implicit_alias() {
|
|||
if [ "_$2" = '_stable' ]; then
|
||||
nvm_echo "${STABLE}"
|
||||
elif [ "_$2" = '_unstable' ]; then
|
||||
nvm_echo "${UNSTABLE}"
|
||||
nvm_echo "${UNSTABLE:-"N/A"}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
|||
N/A
|
|
@ -0,0 +1,12 @@
|
|||
v6.9.1-nightly201610183843b96e46 Boron
|
||||
v6.9.2-nightly201610208bb346d61a Boron
|
||||
v6.9.3-nightly20161206c350268432 Boron
|
||||
v6.9.4-nightly201701049844692719 Boron
|
||||
v6.9.5-nightly2017013187ac44974a Boron
|
||||
v6.9.6-nightly201702013f61aae59d Boron
|
||||
v6.10.1-nightly20170222ee10f21f3b Boron
|
||||
v6.10.2-nightly20170322426968ddd8 Boron
|
||||
v6.10.3-nightly2017040479546c0b5a Boron
|
||||
v6.10.4-nightly20170502312091a196 Boron
|
||||
v6.11.1-nightly20170607f7ca483d68 Boron
|
||||
v8.9.1-nightly20171104a815e1b6a2 Carbon
|
|
@ -0,0 +1,95 @@
|
|||
v0.10.41-nightly20151203036580393d
|
||||
v0.10.42-nightly20160128b125512a5c
|
||||
v0.12.10-nightly20160128a305339f66
|
||||
v4.0.0-nightly201509079cae65c510
|
||||
v5.0.0-nightly201510266a04cc0a43
|
||||
v5.0.1-nightly2015111484bb74547d
|
||||
v5.1.2-nightly201512091c1c1a0f2b
|
||||
v5.2.1-nightly20151210cb938aaa33
|
||||
v5.3.1-nightly20151224b4c51c5b76
|
||||
v5.4.1-nightly20160107138e1e501e
|
||||
v5.4.2-nightly20160121e855b596f4
|
||||
v5.5.1-nightly20160127a8c2050c2d
|
||||
v5.6.1-nightly201602106d8eba0e5e
|
||||
v5.7.1-nightly20160302c83725c604
|
||||
v5.7.2-nightly2016030801c331ea37
|
||||
v5.10.2-nightly201604206d9c0c9aa7
|
||||
v5.11.1-nightly20160504bec5d50f1e
|
||||
v5.11.2-nightly2016062103d36aea4f
|
||||
v6.0.0-nightly20160425eb4201f07a
|
||||
v6.3.1-nightly201607209e9d499b8b
|
||||
v6.3.2-nightly20160815da9bd2fc48
|
||||
v6.4.1-nightly20160825723fa9637c
|
||||
v6.5.1-nightly20160914180867d6a6
|
||||
v6.6.1-nightly20160927f8ad0dc0e2
|
||||
v6.7.1-nightly20161007d7454e7547
|
||||
v6.8.1-nightly201610132540417ef5
|
||||
v6.8.2-nightly201610154613c22b00
|
||||
v6.9.1-nightly201610183843b96e46 Boron
|
||||
v6.9.2-nightly201610208bb346d61a Boron
|
||||
v6.9.3-nightly20161206c350268432 Boron
|
||||
v6.9.4-nightly201701049844692719 Boron
|
||||
v6.9.5-nightly2017013187ac44974a Boron
|
||||
v6.9.6-nightly201702013f61aae59d Boron
|
||||
v6.10.1-nightly20170222ee10f21f3b Boron
|
||||
v6.10.2-nightly20170322426968ddd8 Boron
|
||||
v6.10.3-nightly2017040479546c0b5a Boron
|
||||
v6.10.4-nightly20170502312091a196 Boron
|
||||
v6.11.1-nightly20170607f7ca483d68 Boron
|
||||
v7.0.0-nightly201610246bbdd668bd
|
||||
v7.0.1-nightly2016102527e1749dcb
|
||||
v7.1.1-nightly201611093daf11635d
|
||||
v7.2.0-nightly20161123c1aa949064
|
||||
v7.2.1-nightly201611248cabe28efb
|
||||
v7.2.2-nightly20161207c2cc11b3c6
|
||||
v7.3.1-nightly20161221586967a078
|
||||
v7.4.1-nightly20170104e07b6516d7
|
||||
v7.5.1-nightly2017020113a024d531
|
||||
v7.6.1-nightly201702227a6367017c
|
||||
v7.7.1-nightly201703019c75f4c78a
|
||||
v7.7.2-nightly20170302b20bc130ef
|
||||
v7.7.3-nightly20170309c62798034a
|
||||
v7.7.4-nightly20170315753adee6aa
|
||||
v7.7.5-nightly20170322bc664cb034
|
||||
v7.8.1-nightly20170329517f13b607
|
||||
v7.9.1-nightly20170411675ece47b3
|
||||
v7.10.1-nightly2017050369a8053e8a
|
||||
v8.0.0-nightly20170530effeff1843
|
||||
v8.1.0-nightly20170612f6fc46e036
|
||||
v8.1.1-nightly2017061323318c7661
|
||||
v8.1.2-nightly20170614a1b27dbfb4
|
||||
v8.1.3-nightly201706220b96a2640b
|
||||
v8.1.4-nightly20170704c2c7eb1a41
|
||||
v8.1.5-nightly20170718e9491f1cd4
|
||||
v8.2.1-nightly2017080791b7843aeb
|
||||
v8.3.1-nightly201708182d8d355a5f
|
||||
v8.4.1-nightly201709104b28e0055e
|
||||
v8.5.1-nightly20170921535f8d5281
|
||||
v8.6.1-nightly201710116f42b680e3
|
||||
v8.7.1-nightly2017102478a6ef46a9
|
||||
v8.8.1-nightly201710256fbef7f350
|
||||
v8.8.2-nightly20171030f00ba6b142
|
||||
v8.9.1-nightly20171104a815e1b6a2 Carbon
|
||||
v9.0.0-nightly2017103182790d84f2
|
||||
v9.0.1-nightly20171105ed0fbd8d72
|
||||
v9.1.1-nightly20171207c81e9682c4
|
||||
v9.2.1-nightly20171208f0f9e1abf0
|
||||
v9.2.2-nightly20171212f8143214be
|
||||
v9.3.1-nightly2018010930273d400c
|
||||
v9.4.1-nightly20180124dd56bd1591
|
||||
v9.5.1-nightly20180221b9b58100e0
|
||||
v9.6.1-nightly20180222927c1b1a7e
|
||||
v9.6.2-nightly201802277853a7fd2a
|
||||
v9.7.1-nightly201803013f3995b7b7
|
||||
v9.7.2-nightly20180307cde6671b41
|
||||
v9.8.1-nightly20180320607b33cfcc
|
||||
v9.9.1-nightly201803256591d9f761
|
||||
v9.10.0-nightly201803270a18bf1304
|
||||
v9.10.1-nightly201803284844a263ce
|
||||
v9.10.2-nightly201804042bdf3ca235
|
||||
v9.11.2-nightly201804135d9a7f81ae
|
||||
v10.0.0-nightly20180424982adb5994
|
||||
v10.0.1-nightly20180505ff148b987d
|
||||
v10.1.1-nightly20180523235a272838
|
||||
v10.2.1-nightly20180524be71c5dea9
|
||||
v11.0.0-nightly201805249a02de7084
|
|
@ -0,0 +1 @@
|
|||
v11.0.0-nightly201805249a02de7084
|
|
@ -0,0 +1 @@
|
|||
11.0
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_download
|
||||
}
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
MOCKS_DIR="$PWD/mocks"
|
||||
|
||||
# sample output at the time the test was written
|
||||
TAB_PATH="$MOCKS_DIR/nodejs.org-download-nightly-index.tab"
|
||||
nvm_download() {
|
||||
cat "$TAB_PATH"
|
||||
}
|
||||
|
||||
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote nightly.txt"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote foo)"
|
||||
EXIT_CODE="$(nvm_ls_remote foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote)"
|
||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote 10.0)"
|
||||
EXPECTED_OUTPUT="v10.0.0-nightly20180424982adb5994
|
||||
v10.0.1-nightly20180505ff148b987d"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 10.0 did not output 10.0 nightly versions; got $OUTPUT"
|
||||
|
||||
# Sanity checks
|
||||
OUTPUT="$(nvm_print_implicit_alias remote stable)"
|
||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable nightly.txt"
|
||||
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}")"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
OUTPUT="$(nvm_print_implicit_alias remote unstable)"
|
||||
EXPECTED_OUTPUT="N/A"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote unstable did not output |$EXPECTED_OUTPUT|; got |$OUTPUT|"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote stable)"
|
||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_ls_remote stable nightly.txt"
|
||||
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}")"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote unstable)"
|
||||
EXPECTED_OUTPUT="N/A"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output |$EXPECTED_OUTPUT|; got |$OUTPUT|"
|
||||
|
||||
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote LTS nightly.txt"
|
||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
||||
OUTPUT="$(NVM_LTS='*' nvm_ls_remote)"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS='*' nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
||||
|
||||
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote LTS nightly argon.txt"
|
||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
||||
OUTPUT="$(NVM_LTS=argon nvm_ls_remote)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS=argon nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
||||
|
||||
cleanup
|
|
@ -24,7 +24,7 @@ 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"
|
||||
nvm_download -L -s "$(nvm_get_mirror node std)/index.tab" -o - > "$MOCKS_DIR/nodejs.org-dist-index.tab"
|
||||
nvm_download -L -s "https://nodejs.org/download/nightly/index.tab" -o - > "$MOCKS_DIR/nodejs.org-download-nightly-index.tab"
|
||||
nvm_download -L -s "$(nvm_get_mirror iojs std)/index.tab" -o - > "$MOCKS_DIR/iojs.org-dist-index.tab"
|
||||
nvm ls-remote > "$MOCKS_DIR/nvm ls-remote.txt"
|
||||
nvm ls-remote --lts > "$MOCKS_DIR/nvm ls-remote lts.txt"
|
||||
|
@ -33,6 +33,13 @@ nvm ls-remote iojs > "$MOCKS_DIR/nvm ls-remote iojs.txt"
|
|||
nvm_print_implicit_alias remote stable > "$MOCKS_DIR/nvm_print_implicit_alias remote stable.txt"
|
||||
nvm_ls_remote stable > "$MOCKS_DIR/nvm_ls_remote stable.txt"
|
||||
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote nightly.txt"
|
||||
nvm_download -L -s "$(nvm_get_mirror node std)/index.tab" -o - > "$MOCKS_DIR/nodejs.org-dist-index.tab"
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm_print_implicit_alias remote stable > "$MOCKS_DIR/nvm_print_implicit_alias remote stable nightly.txt"
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm_ls_remote stable > "$MOCKS_DIR/nvm_ls_remote stable nightly.txt"
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ NVM_LTS=* nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote LTS nightly.txt"
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ NVM_LTS=argon nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote LTS nightly argon.txt"
|
||||
|
||||
ALIAS_PATH="$MOCKS_DIR/nvm_make_alias LTS alias calls.txt"
|
||||
: > "$ALIAS_PATH"
|
||||
nvm_make_alias() {
|
||||
|
|
Loading…
Reference in New Issue