playwright/packages/playwright-core/src/cli/commands/ls.ts
robby 018e23da80 add: list installed browsers
Add new commands to list installed browsers.

Solves #34183

* Add `playwright ls` command to list installed browsers in `packages/playwright-core/src/cli/commands/ls.ts`.
* Add `--list` option to `npx playwright install` command in `packages/playwright-core/src/cli/commands/install.ts`.
* Register the new `ls` command in the CLI program in `packages/playwright-core/src/cli/program.ts`.
* Write tests for the `playwright ls` command in `packages/playwright-core/src/cli/commands/ls.test.ts`.
* Add documentation for the new `playwright ls` command and `--list` option in `docs/src/cli.md`.
* Update `.github/actions/run-test/action.yml` to use `npx playwright install --with-deps --list` to list installed browsers.
2025-01-08 13:49:34 -05:00

22 lines
671 B
TypeScript

import { registry } from '../../server';
import { gracefullyProcessExitDoNotHang } from '../../utils';
async function listInstalledBrowsers() {
try {
const executables = registry.executables();
for (const executable of executables) {
if (executable.installType !== 'none') {
console.log(`Browser: ${executable.name}`);
console.log(` Version: ${executable.browserVersion}`);
console.log(` Install location: ${executable.directory}`);
console.log('');
}
}
} catch (e) {
console.log(`Failed to list installed browsers\n${e}`);
gracefullyProcessExitDoNotHang(1);
}
}
export { listInstalledBrowsers };