mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: warn against using globally scoped install (#13196)
This commit is contained in:
parent
b0103566c9
commit
42798b5857
@ -32,7 +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 { spawnAsync, getPlaywrightVersion, wrapInASCIIBox } from '../utils/utils';
|
||||
import { writeDockerVersion } from '../utils/dependencies';
|
||||
import { launchGridAgent } from '../grid/gridAgent';
|
||||
import { GridServer, GridFactory } from '../grid/gridServer';
|
||||
@ -115,6 +115,27 @@ program
|
||||
.option('--with-deps', 'install system dependencies for browsers')
|
||||
.option('--force', 'force reinstall of stable browser channels')
|
||||
.action(async function(args: string[], options: { withDeps?: boolean, force?: boolean }) {
|
||||
const isLikelyNpxGlobal = process.argv.length >= 2 && process.argv[1].includes('_npx');
|
||||
if (isLikelyNpxGlobal) {
|
||||
console.error(wrapInASCIIBox([
|
||||
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
||||
`installing your project's dependencies.`,
|
||||
``,
|
||||
`To avoid unexpected behavior, please install your dependencies first, and`,
|
||||
`then run Playwright's install command:`,
|
||||
``,
|
||||
` npm install`,
|
||||
` npx playwright install`,
|
||||
``,
|
||||
`If your project does not yet depend on Playwright, first install the`,
|
||||
`applicable npm package (most commonly @playwright/test), and`,
|
||||
`then run Playwright's install command to download the browsers:`,
|
||||
``,
|
||||
` npm install @playwright/test`,
|
||||
` npx playwright install`,
|
||||
``,
|
||||
].join('\n'), 1));
|
||||
}
|
||||
try {
|
||||
if (!args.length) {
|
||||
const executables = registry.defaultExecutables();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user