Skip to content

Commit 226e5b8

Browse files
marco-ippolitotargos
authored andcommitted
tools: move update-npm to dep updaters
PR-URL: #47619 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 9d0bef6 commit 226e5b8

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

tools/update-npm.sh tools/dep_updaters/update-npm.sh

+16-13
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
set -e
33
# Shell script to update npm in the source tree to a specific version
44

5-
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
66
DEPS_DIR="$BASE_DIR/deps"
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
9+
10+
NPM="$DEPS_DIR/npm/bin/npm-cli.js"
11+
712
NPM_VERSION=$1
813

914
if [ "$#" -le 0 ]; then
@@ -25,22 +30,17 @@ trap cleanup INT TERM EXIT
2530

2631
cd "$WORKSPACE"
2732

28-
git clone --depth=1 --branch="v$NPM_VERSION" [email protected]:npm/cli.git
29-
cd cli
33+
NPM_TGZ=npm.tgz
3034

31-
echo "Preparing npm release"
35+
NPM_TARBALL="$($NODE "$NPM" view npm@"$NPM_VERSION" dist.tarball)"
3236

33-
make
34-
make release
37+
curl -s "$NPM_TARBALL" > "$NPM_TGZ"
3538

36-
echo "Removing old npm"
39+
rm -rf "$DEPS_DIR/npm"
3740

38-
cd "$DEPS_DIR"
39-
rm -rf npm/
41+
mkdir "$DEPS_DIR/npm"
4042

41-
echo "Copying new npm"
42-
43-
tar zxf "$WORKSPACE/cli/release/npm-$NPM_VERSION.tgz"
43+
tar zxvf "$NPM_TGZ" --strip-component=1 -C "$DEPS_DIR/npm"
4444

4545
echo ""
4646
echo "All done!"
@@ -49,5 +49,8 @@ echo "Please git add npm, commit the new version, and whitespace-fix:"
4949
echo ""
5050
echo "$ git add -A deps/npm"
5151
echo "$ git commit -m \"deps: upgrade npm to $NPM_VERSION\""
52-
echo "$ git rebase --whitespace=fix main"
5352
echo ""
53+
54+
# The last line of the script should always print the new version,
55+
# as we need to add it to $GITHUB_ENV variable.
56+
echo "NEW_VERSION=$NPM_VERSION"

0 commit comments

Comments
 (0)