From 6c60d902777a8214376e23e78d205898755bc502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 23 May 2023 11:45:56 +0200 Subject: [PATCH] tools: fix race condition when npm installing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. PR-URL: https://github.com/nodejs/node/pull/48101 Reviewed-By: Michaƫl Zasso Reviewed-By: Moshe Atlow Reviewed-By: Darshan Sen Reviewed-By: Marco Ippolito Reviewed-By: Mestery Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Yagiz Nizipli --- 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 95aba45397bd4a..3142d4f2d7f0d4 100755 --- a/tools/dep_updaters/update-eslint.sh +++ b/tools/dep_updaters/update-eslint.sh @@ -36,7 +36,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 be7b85c2247ae0..f02bea6e2dbd76 100755 --- a/tools/dep_updaters/update-postject.sh +++ b/tools/dep_updaters/update-postject.sh @@ -29,7 +29,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