From acea7c8ac11a4f4045dc914a72c6f8b065ef7ac7 Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Mon, 17 Aug 2026 21:24:52 +0300 Subject: [PATCH] Build/Test Tools: Remove all `npx` commands. When a binary is missing locally, `npx` installs the package and its dependencies, running every install script. This replaces each `npx` call with `npm exec --no`, which runs an installed binary and fails when the package is missing. Backport of r63309 to the 7.1 branch. --- Gruntfile.js | 10 +++++----- package-lock.json | 1 + package.json | 1 + tests/qunit/playwright.config.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 61f18481e23a8..ab40643d05a80 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2279,8 +2279,8 @@ module.exports = function(grunt) { grunt.registerTask( 'qunit', 'Runs QUnit tests.', function() { var done = this.async(); grunt.util.spawn( { - cmd: 'npx', - args: [ 'playwright', 'test', '--config', 'tests/qunit/playwright.config.js' ], + cmd: 'npm', + args: [ 'exec', '--no', '--', 'playwright', 'test', '--config', 'tests/qunit/playwright.config.js' ], opts: { stdio: 'inherit' } }, function( error, result, code ) { if ( code !== 0 ) { @@ -2363,15 +2363,15 @@ module.exports = function(grunt) { grunt.registerTask( 'wp-packages:update', 'Update WordPress packages', function() { const distTag = grunt.option('dist-tag') || 'latest'; grunt.log.writeln( `Updating WordPress packages (--dist-tag=${distTag})` ); - spawn( 'npx', [ 'wp-scripts', 'packages-update', `--dist-tag=${distTag}` ], { + spawn( 'npm', [ 'exec', '--no', '--', 'wp-scripts', 'packages-update', `--dist-tag=${distTag}` ], { cwd: __dirname, stdio: 'inherit', } ); } ); grunt.registerTask( 'browserslist:update', 'Update the local database of browser supports', function() { - grunt.log.writeln( `Updating browsers list` ); - spawn( 'npx', [ 'update-browserslist-db@latest' ], { + grunt.log.writeln( 'Updating browsers list' ); + spawn( 'npm', [ 'exec', '--no', '--', 'update-browserslist-db' ], { cwd: __dirname, stdio: 'inherit', } ); diff --git a/package-lock.json b/package-lock.json index 78985e8f955c0..43a39bb195c39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,6 +89,7 @@ "sinon-test": "~3.1.6", "source-map-loader": "5.0.0", "typescript": "6.0.3", + "update-browserslist-db": "1.2.3", "uuid": "14.0.1", "wait-on": "9.0.10", "webpack": "5.108.4" diff --git a/package.json b/package.json index e3e14f9828f0f..d2558fc374f78 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "sinon-test": "~3.1.6", "source-map-loader": "5.0.0", "typescript": "6.0.3", + "update-browserslist-db": "1.2.3", "uuid": "14.0.1", "wait-on": "9.0.10", "webpack": "5.108.4" diff --git a/tests/qunit/playwright.config.js b/tests/qunit/playwright.config.js index fc6651e0917ac..9e49301727a6a 100644 --- a/tests/qunit/playwright.config.js +++ b/tests/qunit/playwright.config.js @@ -12,7 +12,7 @@ module.exports = defineConfig( { workers: 1, use: { headless: true, - /* This avoids the need to run `npx playwright install` in CI. */ + /* The system Chrome channel avoids a browser download in CI. */ channel: process.env.CI ? 'chrome' : undefined, }, reporter: process.env.CI ? 'github' : 'list',