feat: introduce npx playwright install docker-image command (#9597)

This command pulls matching docker image for Playwright.
This commit is contained in:
Andrey Lushnikov 2021-10-19 12:30:32 -07:00 committed by GitHub
parent adb5aa4544
commit c5359ff6c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);