Skip to content

Commit 9079604

Browse files
committed
tools: simplify update-undici.sh
1 parent a7f487f commit 9079604

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

tools/dep_updaters/update-undici.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This script must be in the tools directory when it runs because it uses the
66
# script source file path to determine directories to work in.
77

8-
set -e
8+
set -ex
99

1010
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
1111
DEPS_DIR="$ROOT/deps"
@@ -40,29 +40,24 @@ compare_dependency_version "undici" "$NEW_VERSION" "$CURRENT_VERSION"
4040
rm -rf deps/undici/src
4141
rm -f deps/undici/undici.js
4242

43-
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
44-
echo "$WORKSPACE"
43+
TARBALL=$(mktemp 2> /dev/null || mktemp -t 'tmp')
44+
4545
cleanup () {
4646
EXIT_CODE=$?
47-
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
47+
[ -e "$TARBALL" ] && rm "$TARBALL"
4848
exit $EXIT_CODE
4949
}
5050

5151
trap cleanup INT TERM EXIT
5252

53-
UNDICI_ZIP="undici-$NEW_VERSION"
54-
cd "$WORKSPACE"
55-
5653
echo "Fetching UNDICI source archive..."
57-
curl -sL -o "$UNDICI_ZIP.zip" "https://github.com/nodejs/undici/archive/refs/tags/v$NEW_VERSION.zip"
54+
curl -fsSLo "$TARBALL" "https://github.com/nodejs/undici/archive/refs/tags/v$NEW_VERSION.tar.gz"
5855

59-
log_and_verify_sha256sum "undici" "$UNDICI_ZIP.zip"
56+
log_and_verify_sha256sum "undici" "$TARBALL"
6057

6158
echo "Unzipping..."
62-
unzip "$UNDICI_ZIP.zip" -d "src"
63-
mv "src/$UNDICI_ZIP" "$DEPS_DIR/undici/src"
64-
rm "$UNDICI_ZIP.zip"
65-
cd "$ROOT"
59+
tar -xzf "$TARBALL" -C "$DEPS_DIR/undici"
60+
mv "$DEPS_DIR/undici"/undici-* "$DEPS_DIR/undici/src"
6661

6762
(
6863
cd "$DEPS_DIR/undici/src"
@@ -96,8 +91,8 @@ cat > "$ROOT/src/undici_version.h" <<EOF
9691
#endif // SRC_UNDICI_VERSION_H_
9792
EOF
9893

99-
mv deps/undici/src/undici-fetch.js deps/undici/undici.js
100-
cp deps/undici/src/LICENSE deps/undici/LICENSE
94+
mv "$DEPS_DIR/undici/src/undici-fetch.js" "$DEPS_DIR/undici/undici.js"
95+
cp "$DEPS_DIR/undici/src/LICENSE" "$DEPS_DIR/undici/LICENSE"
10196

10297
# Update the version number on maintaining-dependencies.md
10398
# and print the new version as the last line of the script as we need

0 commit comments

Comments
 (0)