Skip to content

Commit 33a2783

Browse files
committed
headless: false will now install binaries for headless mode too
1 parent 7b54c35 commit 33a2783

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/build/src/extensions/playwright.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,29 @@ class PlaywrightExtension implements BuildExtension {
295295
* We save this output to a file and then parse it to get the download urls for the browsers.
296296
*/
297297
instructions.push(`RUN npx playwright install --dry-run > /tmp/browser-info.txt`);
298+
299+
// Determine which browsers to actually install
300+
const browsersToInstall = new Set<PlaywrightBrowser | "chromium-headless-shell">();
301+
298302
this.options.browsers.forEach((browser) => {
299-
const browserType = browser === "chromium" ? "chromium-headless-shell" : browser;
303+
if (browser === "chromium") {
304+
if (this.options.headless) {
305+
// For headless mode, only install chromium-headless-shell
306+
browsersToInstall.add("chromium-headless-shell");
307+
} else {
308+
// For non-headless mode, install both chromium and chromium-headless-shell
309+
// This allows users to easily switch between headless and non-headless mode
310+
browsersToInstall.add("chromium");
311+
browsersToInstall.add("chromium-headless-shell");
312+
}
313+
} else {
314+
browsersToInstall.add(browser);
315+
}
316+
});
317+
318+
Array.from(browsersToInstall).forEach((browser) => {
300319
instructions.push(
301-
`RUN grep -A5 "browser: ${browserType}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`,
320+
`RUN grep -A5 -m1 "browser: ${browser}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`,
302321

303322
`RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
304323
DIR_NAME=$(basename "$INSTALL_DIR") && \

0 commit comments

Comments
 (0)