From 95ca08fdb795d892771e893bc0b40b884bbfc8ca Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 9 May 2025 14:16:04 +0200 Subject: [PATCH] fix: use of wrong launchOptions type in public API (#385) --- config.d.ts | 2 +- src/config.ts | 2 +- src/context.ts | 2 +- src/tools/install.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.d.ts b/config.d.ts index 6b01c22..587b657 100644 --- a/config.d.ts +++ b/config.d.ts @@ -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. diff --git a/src/config.ts b/src/config.ts index 5fc7643..3f12c52 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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 { diff --git a/src/context.ts b/src/context.ts index ec46b9a..76f461c 100644 --- a/src/context.ts +++ b/src/context.ts @@ -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; } diff --git a/src/tools/install.ts b/src/tools/install.ts index afa3247..d0d5145 100644 --- a/src/tools/install.ts +++ b/src/tools/install.ts @@ -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], {