From 77fa8b0468b7d8c87c6dfbfbb96d03989bb3d3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 21 May 2023 11:36:28 +0200 Subject: [PATCH] tools: fix race condition when npm installing The update scripts that install dependencies from npm blindly assume that `npm install` will always install the version that was previously fetched as `dist-tags.latest`. That is not necessarily true, so instead always install the specific version that the script thinks is current. --- tools/dep_updaters/update-acorn-walk.sh | 2 +- tools/dep_updaters/update-acorn.sh | 2 +- tools/dep_updaters/update-cjs-module-lexer.sh | 2 +- tools/dep_updaters/update-eslint.sh | 2 +- tools/dep_updaters/update-minimatch.sh | 2 +- tools/dep_updaters/update-postject.sh | 2 +- tools/dep_updaters/update-undici.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/dep_updaters/update-acorn-walk.sh b/tools/dep_updaters/update-acorn-walk.sh index c90da38bce2cee..3089a17ba7dba1 100755 --- a/tools/dep_updaters/update-acorn-walk.sh +++ b/tools/dep_updaters/update-acorn-walk.sh @@ -33,7 +33,7 @@ rm -rf deps/acorn/acorn-walk "$NODE" "$NPM" init --yes - "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts acorn-walk + "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn-walk@$NEW_VERSION" ) mv acorn-walk-tmp/node_modules/acorn-walk deps/acorn diff --git a/tools/dep_updaters/update-acorn.sh b/tools/dep_updaters/update-acorn.sh index 6e43973c4f73d9..4f6bf6b0dd7a43 100755 --- a/tools/dep_updaters/update-acorn.sh +++ b/tools/dep_updaters/update-acorn.sh @@ -33,7 +33,7 @@ rm -rf deps/acorn/acorn "$NODE" "$NPM" init --yes - "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts acorn + "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn@$NEW_VERSION" cd node_modules/acorn # update this version information in src/acorn_version.h FILE_PATH="$ROOT/src/acorn_version.h" diff --git a/tools/dep_updaters/update-cjs-module-lexer.sh b/tools/dep_updaters/update-cjs-module-lexer.sh index 3e080182088c40..151a57ebb07460 100755 --- a/tools/dep_updaters/update-cjs-module-lexer.sh +++ b/tools/dep_updaters/update-cjs-module-lexer.sh @@ -44,7 +44,7 @@ cd "$WORKSPACE" "$NODE" "$NPM" init --yes -"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts cjs-module-lexer +"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "cjs-module-lexer@$NEW_VERSION" rm -rf "$DEPS_DIR/cjs-module-lexer" diff --git a/tools/dep_updaters/update-eslint.sh b/tools/dep_updaters/update-eslint.sh index b3025bb8ff9e7e..a5f0b5eeb6e3d7 100755 --- a/tools/dep_updaters/update-eslint.sh +++ b/tools/dep_updaters/update-eslint.sh @@ -34,7 +34,7 @@ rm -rf ../node_modules/eslint --ignore-scripts \ --install-strategy=shallow \ --no-bin-links \ - eslint + "eslint@$NEW_VERSION" # Uninstall plugins that we want to install so that they are removed from # devDependencies. Otherwise --omit=dev will cause them to be skipped. ( diff --git a/tools/dep_updaters/update-minimatch.sh b/tools/dep_updaters/update-minimatch.sh index 55c9575fb9a764..020de42cdecb47 100755 --- a/tools/dep_updaters/update-minimatch.sh +++ b/tools/dep_updaters/update-minimatch.sh @@ -34,7 +34,7 @@ rm -rf deps/minimatch/index.js "$NODE" "$NPM" init --yes - "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts minimatch + "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "minimatch@$NEW_VERSION" cd node_modules/minimatch "$NODE" "$NPM" exec --package=esbuild@0.17.15 --yes -- esbuild ./dist/cjs/index.js --bundle --platform=node --outfile=minimatch.js ) diff --git a/tools/dep_updaters/update-postject.sh b/tools/dep_updaters/update-postject.sh index f7a63ce1816cf9..86de9c56adc151 100755 --- a/tools/dep_updaters/update-postject.sh +++ b/tools/dep_updaters/update-postject.sh @@ -27,7 +27,7 @@ cd test/fixtures/postject-copy || exit "$NODE" "$NPM" init --yes -"$NODE" "$NPM" install --no-bin-links --ignore-scripts postject +"$NODE" "$NPM" install --no-bin-links --ignore-scripts "postject@$NEW_VERSION" # TODO(RaisinTen): Replace following with $WORKSPACE cd ../../.. diff --git a/tools/dep_updaters/update-undici.sh b/tools/dep_updaters/update-undici.sh index 68b16b90873a23..f9d40fd3fa1e9e 100755 --- a/tools/dep_updaters/update-undici.sh +++ b/tools/dep_updaters/update-undici.sh @@ -33,7 +33,7 @@ rm -f deps/undici/undici.js "$NODE" "$NPM" init --yes - "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts undici + "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "undici@$NEW_VERSION" cd node_modules/undici "$NODE" "$NPM" run build:node # update this version information in src/undici_version.h