add --list and npm run list
This commit is contained in:
parent
6179b5b1d7
commit
27b5ad546d
|
|
@ -45,7 +45,8 @@
|
|||
"roll": "node utils/roll_browser.js",
|
||||
"check-deps": "node utils/check_deps.js",
|
||||
"build-android-driver": "./utils/build_android_driver.sh",
|
||||
"innerloop": "playwright run-server --reuse-browser"
|
||||
"innerloop": "playwright run-server --reuse-browser",
|
||||
"list": "playwright install --list"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
|
|
|
|||
|
|
@ -232,6 +232,39 @@ Examples:
|
|||
- $ install-deps chrome firefox
|
||||
Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);
|
||||
|
||||
program
|
||||
.command('show-browsers') // Changed from 'install --list' to avoid conflicts
|
||||
.alias('list-browsers') // Added alias for convenience
|
||||
.description('lists installed browsers and their paths')
|
||||
.action(async function () {
|
||||
try {
|
||||
const browsers = new Set();
|
||||
// Filter once instead of twice
|
||||
const installableBrowsers = registry.executables().filter(e =>
|
||||
e.installType !== 'none' &&
|
||||
e.type !== 'tool'
|
||||
);
|
||||
|
||||
if (installableBrowsers.length === 0) {
|
||||
console.log('No browsers installed. To install them use: npx playwright install');
|
||||
return;
|
||||
}
|
||||
|
||||
for (const executable of installableBrowsers) {
|
||||
try {
|
||||
const version = executable.browserVersion ? `v${executable.browserVersion}` : '';
|
||||
const location = executable.directory || '<system>';
|
||||
console.log(`${executable.name} ${version ? version + ' ' : ''}${location ? `(${location})` : ''}`);
|
||||
browsers.add(executable.name);
|
||||
} catch (e) {
|
||||
console.error(`Failed to get info for browser ${executable.name}:`, e);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logErrorAndExit(e);
|
||||
}
|
||||
});
|
||||
|
||||
const browsers = [
|
||||
{ alias: 'cr', name: 'Chromium', type: 'chromium' },
|
||||
{ alias: 'ff', name: 'Firefox', type: 'firefox' },
|
||||
|
|
|
|||
Loading…
Reference in a new issue