Skip to content

Commit bd62771

Browse files
ruyadornodanielleadams
authored andcommitted
tools: use bundled npm in update scripts
The scripts `./tools/update-babel-eslint.sh` and `./tools/update-eslint.sh` are relying on the version of `npm` found in the local-defined `$PATH` env. This changeset proposes to modify these scripts to run the version of npm bundled in the current branch (found at `./deps/npm`) - in order to: a) Standardize the version of npm that should be use to install these deps, avoids the pitfall of having an inadverted user run these scripts with an unsupported/incompatible npm version. b) Given that npm7 has a different install algorithm than npm6 that takes into account and install peer dependencies, it might be a safer choice to ensure what version of npm should be use during this transitional period in which users might still have npm6 by default in their local system. c) Avoids the possible extra churn of having different resulting files being shuffled around between installs due to usage of a disparate version of the npm cli. PR-URL: #37613 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 5a49e31 commit bd62771

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

tools/update-babel-eslint.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22

33
# Shell script to update babel-eslint in the source tree to the latest release.
44

5-
# Depends on npm, npx, and node being in $PATH.
6-
75
# This script must be be in the tools directory when it runs because it uses
86
# $0 to determine directories to work in.
97

108
cd "$( dirname "${0}" )" || exit
119
rm -rf node_modules/@babel
1210
mkdir babel-eslint-tmp
1311
cd babel-eslint-tmp || exit
14-
npm init --yes
1512

16-
npm install --global-style --no-bin-links --production --no-package-lock @babel/core @babel/eslint-parser@latest @babel/plugin-syntax-class-properties@latest @babel/plugin-syntax-top-level-await@latest
13+
ROOT="$PWD/../.."
14+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
15+
[ -x "$NODE" ] || NODE=`command -v node`
16+
NPM="$ROOT/deps/npm"
17+
18+
"$NODE" "$NPM" init --yes
19+
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock @babel/core @babel/eslint-parser@latest @babel/plugin-syntax-class-properties@latest @babel/plugin-syntax-top-level-await@latest
1720

1821
# Use dmn to remove some unneeded files.
19-
npx dmn@2.2.2 -f clean
22+
"$NODE" "$NPM" exec -- dmn@2.2.2 -f clean
2023
# Use removeNPMAbsolutePaths to remove unused data in package.json.
2124
# This avoids churn as absolute paths can change from one dev to another.
22-
npx removeNPMAbsolutePaths@1.0.4 .
25+
"$NODE" "$NPM" exec -- removeNPMAbsolutePaths@1.0.4 .
2326

2427
cd ..
2528
mv babel-eslint-tmp/node_modules/@babel node_modules/@babel

tools/update-eslint.sh

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
# Shell script to update ESLint in the source tree to the latest release.
44

5-
# Depends on npm, npx, and node being in $PATH.
6-
75
# This script must be in the tools directory when it runs because it uses the
86
# script source file path to determine directories to work in.
97

@@ -12,16 +10,22 @@ rm -rf node_modules/eslint node_modules/eslint-plugin-markdown
1210
(
1311
mkdir eslint-tmp
1412
cd eslint-tmp || exit
15-
npm init --yes
1613

17-
npm install --global-style --no-bin-links --production --no-package-lock eslint@latest
18-
npm install --global-style --no-bin-links --production --no-package-lock eslint-plugin-markdown@latest
14+
ROOT="$PWD/../.."
15+
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
16+
[ -x "$NODE" ] || NODE=`command -v node`
17+
NPM="$ROOT/deps/npm"
18+
19+
"$NODE" "$NPM" init --yes
20+
21+
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock eslint@latest
22+
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock eslint-plugin-markdown@latest
1923

2024
# Use dmn to remove some unneeded files.
21-
npx dmn@2.2.2 -f clean
25+
"$NODE" "$NPM" exec -- dmn@2.2.2 -f clean
2226
# Use removeNPMAbsolutePaths to remove unused data in package.json.
2327
# This avoids churn as absolute paths can change from one dev to another.
24-
npx removeNPMAbsolutePaths@1.0.4 .
28+
"$NODE" "$NPM" exec -- removeNPMAbsolutePaths@1.0.4 .
2529
)
2630

2731
mv eslint-tmp/node_modules/eslint node_modules/eslint

0 commit comments

Comments
 (0)