Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 073424c

Browse filesBrowse files
burnettkkburnett
authored and
kburnett
committed
only touch list-all and stop hitting http endpoint, per code review suggestion
1 parent eb110f8 commit 073424c
Copy full SHA for 073424c

File tree

Expand file treeCollapse file tree

2 files changed

+26
-35
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-35
lines changed

‎bin/list-all

Copy file name to clipboardExpand all lines: bin/list-all
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ set -o nounset -o pipefail -o errexit
1212
# shellcheck source=../lib/utils.sh
1313
source "$(dirname "$0")/../lib/utils.sh"
1414

15+
function print_only_fully_numeric_items() {
16+
local version_numbers="$1"
17+
grep -E '^[0-9.]+$' <<< "$version_numbers"
18+
}
19+
20+
asdf_nodejs_bin_dir="$(dirname "$0")"
21+
all_definitions_from_node_build="$("${asdf_nodejs_bin_dir}/../.node-build/bin/node-build" --definitions)"
22+
1523
# Print
1624
echo $(
17-
# Only print the first column of candidates
18-
print_index_tab | cut -f1 | tac
25+
printf "%s\n" lts-{argon,boron,carbon,dubnium,erbium,fermium,gallium} lts
26+
print_only_fully_numeric_items "$all_definitions_from_node_build"
1927
)

‎lib/utils.sh

Copy file name to clipboardExpand all lines: lib/utils.sh
+16-33Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ die() {
4040
# Print all alias and correspondent versions in the format "$alias\t$version"
4141
# Also prints versions as a alias of itself. Eg: "v10.0.0\tv10.0.0"
4242
filter_version_candidates() {
43-
local version_definitions_available_in_local_node_build="$1"
4443
local curr_line="" aliases=""
4544

4645
# Skip headers
@@ -52,34 +51,24 @@ filter_version_candidates() {
5251

5352
# Version without `v` prefix
5453
local version="${fields[0]#v}"
55-
56-
# if we couldn't find version_definitions_available_in_local_node_build, then just don't filter using that.
57-
# filtering by version_definitions_available_in_local_node_build prevents situations like the following, where:
58-
# asdf list-all nodejs # returns 17.7.1
59-
# but
60-
# asdf install nodejs 17.7.1
61-
# doesn't work because the local version of node-build doesn't include the
62-
# definition for 17.7.1 yet (as was the case on 2022-03011).
63-
if [[ -z "$version_definitions_available_in_local_node_build" ]] || grep -Eq "^${version}$" <<< "$version_definitions_available_in_local_node_build"; then
64-
# Lowercase lts codename, `-` if not a lts version
65-
local lts_codename=$(echo "${fields[9]}" | tr '[:upper:]' '[:lower:]')
66-
67-
if [ "$lts_codename" != - ]; then
68-
# No lts read yet, so this must be the more recent
69-
if ! grep -q "^lts:" <<< "$aliases"; then
70-
printf "lts\t%s\n" "$version"
71-
aliases="$aliases"$'\n'"lts:$version"
72-
fi
73-
74-
# No lts read for this codename yet, so this must be the more recent
75-
if ! grep -q "^$lts_codename:" <<< "$aliases"; then
76-
printf "lts-$lts_codename\t%s\n" "$version"
77-
aliases="$aliases"$'\n'"$lts_codename:$version"
78-
fi
54+
# Lowercase lts codename, `-` if not a lts version
55+
local lts_codename=$(echo "${fields[9]}" | tr '[:upper:]' '[:lower:]')
56+
57+
if [ "$lts_codename" != - ]; then
58+
# No lts read yet, so this must be the more recent
59+
if ! grep -q "^lts:" <<< "$aliases"; then
60+
printf "lts\t%s\n" "$version"
61+
aliases="$aliases"$'\n'"lts:$version"
7962
fi
8063

81-
printf "%s\t%s\n" "$version" "$version"
64+
# No lts read for this codename yet, so this must be the more recent
65+
if ! grep -q "^$lts_codename:" <<< "$aliases"; then
66+
printf "lts-$lts_codename\t%s\n" "$version"
67+
aliases="$aliases"$'\n'"$lts_codename:$version"
68+
fi
8269
fi
70+
71+
printf "%s\t%s\n" "$version" "$version"
8372
done
8473
}
8574

@@ -97,18 +86,12 @@ print_index_tab(){
9786
etag_flag='--header If-None-Match:'"$(cat "$etag_file")"
9887
fi
9988

100-
local asdf_nodejs_bin_dir
101-
asdf_nodejs_bin_dir="$(dirname "$0")"
102-
local definitions_available_in_local_node_build=""
103-
if [[ -f "${asdf_nodejs_bin_dir}/../.node-build/bin/node-build" ]]; then
104-
definitions_available_in_local_node_build="$("${asdf_nodejs_bin_dir}/../.node-build/bin/node-build" --definitions)"
105-
fi
10689
index="$(curl --fail --silent --dump-header "$temp_headers_file" $etag_flag "${NODEJS_ORG_MIRROR}index.tab")"
10790
if [ -z "$index" ]; then
10891
cat "$index_file"
10992
else
11093
cat "$temp_headers_file" | awk 'tolower($1) == "etag:" { print $2 }' > "$etag_file"
111-
echo "$index" | filter_version_candidates "$definitions_available_in_local_node_build" > "$index_file"
94+
echo "$index" | filter_version_candidates > "$index_file"
11295
cat "$index_file"
11396
fi
11497

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.