Skip to content

Commit 021cf91

Browse files
authored
tools: allow local updates for llhttp
PR-URL: nodejs#52085 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent 7c02486 commit 021cf91

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

tools/dep_updaters/update-llhttp.sh

+28-12
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ DEPS_DIR="${BASE_DIR}/deps"
1212
# shellcheck disable=SC1091
1313
. "$BASE_DIR/tools/dep_updaters/utils.sh"
1414

15-
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
16-
const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest',
17-
process.env.GITHUB_TOKEN && {
18-
headers: {
19-
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
20-
},
21-
});
22-
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
23-
const { tag_name } = await res.json();
24-
console.log(tag_name.replace('release/v', ''));
15+
if [ -n "$LOCAL_COPY" ]; then
16+
NEW_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$LOCAL_COPY/package.json', 'utf-8')).version)")
17+
else
18+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
19+
const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest',
20+
process.env.GITHUB_TOKEN && {
21+
headers: {
22+
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
23+
},
24+
});
25+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
26+
const { tag_name } = await res.json();
27+
console.log(tag_name.replace('release/v', ''));
2528
EOF
2629
)"
30+
fi
2731

2832
CURRENT_MAJOR_VERSION=$(grep "#define LLHTTP_VERSION_MAJOR" ./deps/llhttp/include/llhttp.h | sed -n "s/^.*MAJOR \(.*\)/\1/p")
2933
CURRENT_MINOR_VERSION=$(grep "#define LLHTTP_VERSION_MINOR" ./deps/llhttp/include/llhttp.h | sed -n "s/^.*MINOR \(.*\)/\1/p")
@@ -48,7 +52,19 @@ cd "$WORKSPACE"
4852
echo "Replacing existing llhttp (except GYP and GN build files)"
4953
mv "$DEPS_DIR/llhttp/"*.gn "$DEPS_DIR/llhttp/"*.gni "$WORKSPACE/"
5054

51-
if echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release
55+
if [ -n "$LOCAL_COPY" ]; then
56+
echo "Copying llhttp release from $LOCAL_COPY ..."
57+
58+
echo "Building llhttp ..."
59+
cd "$BASE_DIR"
60+
cd "$LOCAL_COPY"
61+
npm install
62+
RELEASE=$NEW_VERSION make release
63+
64+
echo "Copying llhttp release ..."
65+
rm -rf "$DEPS_DIR/llhttp"
66+
cp -a release "$DEPS_DIR/llhttp"
67+
elif echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release
5268
REPO="git@github.com:$NEW_VERSION.git"
5369
BRANCH=$2
5470
[ -z "$BRANCH" ] && BRANCH=main
@@ -61,7 +77,7 @@ if echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release
6177

6278
echo "Building llhttp ..."
6379
npm install
64-
make release
80+
RELEASE=$NEW_VERSION make release
6581

6682
echo "Copying llhttp release ..."
6783
rm -rf "$DEPS_DIR/llhttp"

tools/dep_updaters/update-openssl.sh

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ main() {
120120
* )
121121
echo "unknown command: $1"
122122
help 1
123+
124+
# shellcheck disable=SC2317
123125
exit 1
124126
;;
125127
esac

0 commit comments

Comments
 (0)