fix: use of wrong launchOptions type in public API (#385)

This commit is contained in:
Max Schmitt 2025-05-09 14:16:04 +02:00 committed by GitHub
parent 053c2f3d32
commit 95ca08fdb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 4 deletions

2
config.d.ts vendored
View File

@ -40,7 +40,7 @@ export type Config = {
*
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
*/
launchOptions?: playwright.BrowserLaunchOptions;
launchOptions?: playwright.LaunchOptions;
/**
* Context options for the browser context.

View File

@ -175,7 +175,7 @@ function mergeConfig(base: Config, overrides: Config): Config {
},
};
if (browser.browserName !== 'chromium')
if (browser.browserName !== 'chromium' && browser.launchOptions)
delete browser.launchOptions.channel;
return {

View File

@ -374,7 +374,7 @@ async function createUserDataDir(browserConfig: Config['browser']) {
cacheDirectory = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
else
throw new Error('Unsupported platform: ' + process.platform);
const result = path.join(cacheDirectory, 'ms-playwright', `mcp-${browserConfig?.launchOptions.channel ?? browserConfig?.browserName}-profile`);
const result = path.join(cacheDirectory, 'ms-playwright', `mcp-${browserConfig?.launchOptions?.channel ?? browserConfig?.browserName}-profile`);
await fs.promises.mkdir(result, { recursive: true });
return result;
}

View File

@ -33,7 +33,7 @@ const install = defineTool({
},
handle: async context => {
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.launchOptions.browserName ?? 'chrome';
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? 'chrome';
const cliUrl = import.meta.resolve('playwright/package.json');
const cliPath = path.join(fileURLToPath(cliUrl), '..', 'cli.js');
const child = fork(cliPath, ['install', channel], {