From c5359ff6c5a6cd3e40879badc8ad639eee0a0fcc Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 19 Oct 2021 12:30:32 -0700 Subject: [PATCH] feat: introduce `npx playwright install docker-image` command (#9597) This command pulls matching docker image for Playwright. --- packages/playwright-core/src/cli/cli.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.ts index 7fedb12192..65c0e30ead 100755 --- a/packages/playwright-core/src/cli/cli.ts +++ b/packages/playwright-core/src/cli/cli.ts @@ -32,6 +32,7 @@ import { BrowserType } from '../client/browserType'; import { BrowserContextOptions, LaunchOptions } from '../client/types'; import { spawn } from 'child_process'; import { registry, Executable } from '../utils/registry'; +import { spawnAsync, getPlaywrightVersion } from '../utils/utils'; import { launchGridAgent } from '../grid/gridAgent'; import { launchGridServer } from '../grid/gridServer'; @@ -111,6 +112,17 @@ program await registry.installDeps(executables); await registry.install(executables); } else { + const installDockerImage = args.some(arg => arg === 'docker-image'); + args = args.filter(arg => arg !== 'docker-image'); + if (installDockerImage) { + const imageName = `mcr.microsoft.com/playwright:v${getPlaywrightVersion()}`; + const { code } = await spawnAsync('docker', ['pull', imageName], { stdio: 'inherit' }); + if (code !== 0) { + console.log('Failed to pull docker image'); + process.exit(1); + } + } + const executables = checkBrowsersToInstall(args); if (options.withDeps) await registry.installDeps(executables);