Merge pull request #21453 from timvandermeij/puppeteer-skip-download

Don't download Puppeteer browsers on `npm install`
This commit is contained in:
calixteman 2026-06-14 19:25:32 +02:00 committed by GitHub
commit 92bd2dbb38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -1,9 +1,13 @@
{ {
"chrome": { "chrome": {
"skipDownload": false "skipDownload": true,
"version": "stable"
},
"chrome-headless-shell": {
"skipDownload": true
}, },
"firefox": { "firefox": {
"skipDownload": false, "skipDownload": true,
"version": "nightly" "version": "nightly"
} }
} }

View File

@ -28,6 +28,7 @@ import {
downloadManifestFiles, downloadManifestFiles,
verifyManifestFiles, verifyManifestFiles,
} from "./downloadutils.mjs"; } from "./downloadutils.mjs";
import { execSync } from "child_process";
import fs from "fs"; import fs from "fs";
import istanbulCoverage from "istanbul-lib-coverage"; import istanbulCoverage from "istanbul-lib-coverage";
import istanbulReportGenerator from "istanbul-reports"; import istanbulReportGenerator from "istanbul-reports";
@ -1095,9 +1096,13 @@ async function startBrowser({
} }
async function startBrowsers({ baseUrl, initializeSession, numSessions = 1 }) { async function startBrowsers({ baseUrl, initializeSession, numSessions = 1 }) {
// Remove old browser revisions from Puppeteer's cache. Updating Puppeteer can // Install the browsers.
// cause new browser revisions to be downloaded, so trimming the cache will for (const browser of ["firefox@nightly", "chrome@stable"]) {
// prevent the disk from filling up over time. execSync(`npx puppeteer browsers install ${browser}`, { stdio: "inherit" });
}
// Remove old browser revisions from Puppeteer's cache. The commands above can
// download new browser revisions, so this prevents the disk from filling up.
await puppeteer.trimCache(); await puppeteer.trimCache();
const browserNames = ["firefox", "chrome"]; const browserNames = ["firefox", "chrome"];