Skip to content

Commit 58a4c7c

Browse files
committed
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.
1 parent 49342fe commit 58a4c7c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

tools/update-babel-eslint.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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.
5+
# Depends on node being in $PATH.
66

77
# This script must be be in the tools directory when it runs because it uses
88
# $0 to determine directories to work in.
@@ -11,15 +11,16 @@ cd "$( dirname "${0}" )" || exit
1111
rm -rf node_modules/@babel
1212
mkdir babel-eslint-tmp
1313
cd babel-eslint-tmp || exit
14-
npm init --yes
14+
NPMCLI="../../deps/npm"
15+
node "$NPMCLI" init --yes
1516

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
17+
node "$NPMCLI" 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
1718

1819
# Use dmn to remove some unneeded files.
19-
npx dmn@2.2.2 -f clean
20+
node "$NPMCLI" exec -- dmn@2.2.2 -f clean
2021
# Use removeNPMAbsolutePaths to remove unused data in package.json.
2122
# This avoids churn as absolute paths can change from one dev to another.
22-
npx removeNPMAbsolutePaths@1.0.4 .
23+
node "$NPMCLI" exec -- removeNPMAbsolutePaths@1.0.4 .
2324

2425
cd ..
2526
mv babel-eslint-tmp/node_modules/@babel node_modules/@babel

tools/update-eslint.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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.
5+
# Depends on node being in $PATH.
66

77
# This script must be in the tools directory when it runs because it uses the
88
# script source file path to determine directories to work in.
@@ -12,16 +12,17 @@ rm -rf node_modules/eslint node_modules/eslint-plugin-markdown
1212
(
1313
mkdir eslint-tmp
1414
cd eslint-tmp || exit
15-
npm init --yes
15+
NPMCLI="../../deps/npm"
16+
node "$NPMCLI" init --yes
1617

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
18+
node "$NPMCLI" install --global-style --no-bin-links --production --no-package-lock eslint@latest
19+
node "$NPMCLI" install --global-style --no-bin-links --production --no-package-lock eslint-plugin-markdown@latest
1920

2021
# Use dmn to remove some unneeded files.
21-
npx dmn@2.2.2 -f clean
22+
node "$NPMCLI" exec -- dmn@2.2.2 -f clean
2223
# Use removeNPMAbsolutePaths to remove unused data in package.json.
2324
# This avoids churn as absolute paths can change from one dev to another.
24-
npx removeNPMAbsolutePaths@1.0.4 .
25+
node "$NPMCLI" exec -- removeNPMAbsolutePaths@1.0.4 .
2526
)
2627

2728
mv eslint-tmp/node_modules/eslint node_modules/eslint

0 commit comments

Comments
 (0)