Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ace4a86

Browse files
marco-ippolitoalexfernandez
authored andcommittedNov 1, 2023
tools: avoid npm install in deps installation
PR-URL: nodejs#50413 Refs: nodejs#49747 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d0886c2 commit ace4a86

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed
 

‎tools/dep_updaters/update-acorn-walk.sh

+31-14
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
set -ex
99

10-
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
11-
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
10+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
11+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
1212
[ -x "$NODE" ] || NODE=$(command -v node)
13-
NPM="$ROOT/deps/npm/bin/npm-cli.js"
13+
NPM="$BASE_DIR/deps/npm/bin/npm-cli.js"
14+
DEPS_DIR="$BASE_DIR/deps"
1415

1516
# shellcheck disable=SC1091
16-
. "$ROOT/tools/dep_updaters/utils.sh"
17+
. "$BASE_DIR/tools/dep_updaters/utils.sh"
1718

1819
NEW_VERSION=$("$NODE" "$NPM" view acorn-walk dist-tags.latest)
1920
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn-walk/package.json').version")
@@ -23,21 +24,37 @@ compare_dependency_version "acorn-walk" "$NEW_VERSION" "$CURRENT_VERSION"
2324

2425
cd "$( dirname "$0" )/../.." || exit
2526

26-
rm -rf deps/acorn/acorn-walk
27+
echo "Making temporary workspace..."
2728

28-
(
29-
rm -rf acorn-walk-tmp
30-
mkdir acorn-walk-tmp
31-
cd acorn-walk-tmp || exit
29+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
3230

33-
"$NODE" "$NPM" init --yes
31+
cleanup () {
32+
EXIT_CODE=$?
33+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
34+
exit $EXIT_CODE
35+
}
3436

35-
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn-walk@$NEW_VERSION"
36-
)
37+
trap cleanup INT TERM EXIT
3738

38-
mv acorn-walk-tmp/node_modules/acorn-walk deps/acorn
39+
cd "$WORKSPACE"
3940

40-
rm -rf acorn-walk-tmp/
41+
echo "Fetching acorn-walk source archive..."
42+
43+
DIST_URL=$(curl -sL "https://registry.npmjs.org/acorn-walk/$NEW_VERSION" | perl -n -e '/"dist".*?"tarball":"(.*?)"/ && print $1')
44+
45+
ACORN_WALK_TGZ="acorn-walk.tgz"
46+
47+
curl -sL -o "$ACORN_WALK_TGZ" "$DIST_URL"
48+
49+
log_and_verify_sha256sum "acorn-walk" "$ACORN_WALK_TGZ"
50+
51+
rm -r "$DEPS_DIR/acorn/acorn-walk"/*
52+
53+
tar -xf "$ACORN_WALK_TGZ"
54+
55+
mv "$WORKSPACE/package"/* "$DEPS_DIR/acorn/acorn-walk"
56+
57+
rm "$ACORN_WALK_TGZ"
4158

4259
echo "All done!"
4360
echo ""

0 commit comments

Comments
 (0)
Please sign in to comment.