◐ Shell
clean mode source ↗

tools: simplify `update-undici.sh` · nodejs/node@b133019

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"

@@ -36,29 +36,24 @@ compare_dependency_version "undici" "$NEW_VERSION" "$CURRENT_VERSION"

3636

rm -rf deps/undici/src

3737

rm -f deps/undici/undici.js

3838
39-

WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')

40-

echo "$WORKSPACE"

39+

TARBALL=$(mktemp 2> /dev/null || mktemp -t 'tmp')

40+
4141

cleanup () {

4242

EXIT_CODE=$?

43-

[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"

43+

[ -e "$TARBALL" ] && rm "$TARBALL"

4444

exit $EXIT_CODE

4545

}

4646
4747

trap cleanup INT TERM EXIT

4848
49-

UNDICI_ZIP="undici-$NEW_VERSION"

50-

cd "$WORKSPACE"

51-
5249

echo "Fetching UNDICI source archive..."

53-

curl -sL -o "$UNDICI_ZIP.zip" "https://github.com/nodejs/undici/archive/refs/tags/v$NEW_VERSION.zip"

50+

curl -fsSLo "$TARBALL" "https://github.com/nodejs/undici/archive/refs/tags/v$NEW_VERSION.tar.gz"

5451
55-

log_and_verify_sha256sum "undici" "$UNDICI_ZIP.zip"

52+

log_and_verify_sha256sum "undici" "$TARBALL"

5653
5754

echo "Unzipping..."

58-

unzip "$UNDICI_ZIP.zip" -d "src"

59-

mv "src/$UNDICI_ZIP" "$DEPS_DIR/undici/src"

60-

rm "$UNDICI_ZIP.zip"

61-

cd "$ROOT"

55+

tar -xzf "$TARBALL" -C "$DEPS_DIR/undici"

56+

mv "$DEPS_DIR/undici"/undici-* "$DEPS_DIR/undici/src"

6257
6358

(

6459

cd "$DEPS_DIR/undici/src"

@@ -92,8 +87,8 @@ cat > "$ROOT/src/undici_version.h" <<EOF

9287

#endif // SRC_UNDICI_VERSION_H_

9388

EOF

9489
95-

mv deps/undici/src/undici-fetch.js deps/undici/undici.js

96-

cp deps/undici/src/LICENSE deps/undici/LICENSE

90+

mv "$DEPS_DIR/undici/src/undici-fetch.js" "$DEPS_DIR/undici/undici.js"

91+

cp "$DEPS_DIR/undici/src/LICENSE" "$DEPS_DIR/undici/LICENSE"

9792
9893

# Update the version number on maintaining-dependencies.md

9994

# and print the new version as the last line of the script as we need