chore: store channel profiles separately (#297)

This commit is contained in:
Pavel Feldman 2025-04-29 13:34:56 -07:00 committed by GitHub
parent 6efdc90078
commit 21d2f80fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -83,9 +83,9 @@ The Playwright MCP server supports the following command-line options:
Playwright MCP will launch the browser with the new profile, located at Playwright MCP will launch the browser with the new profile, located at
``` ```
- `%USERPROFILE%\AppData\Local\ms-playwright\mcp-chromium-profile` on Windows - `%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile` on Windows
- `~/Library/Caches/ms-playwright/mcp-chromium-profile` on macOS - `~/Library/Caches/ms-playwright/mcp-{channel}-profile` on macOS
- `~/.cache/ms-playwright/mcp-chromium-profile` on Linux - `~/.cache/ms-playwright/mcp-{channel}-profile` on Linux
``` ```
All the logged in information will be stored in that profile, you can delete it between sessions if you'd like to clear the offline state. All the logged in information will be stored in that profile, you can delete it between sessions if you'd like to clear the offline state.

View File

@ -96,7 +96,7 @@ export async function configFromCLIOptions(cliOptions: CLIOptions): Promise<Conf
return { return {
browser: { browser: {
browserName, browserName,
userDataDir: cliOptions.userDataDir ?? await createUserDataDir(browserName), userDataDir: cliOptions.userDataDir ?? await createUserDataDir({ browserName, channel }),
launchOptions, launchOptions,
cdpEndpoint: cliOptions.cdpEndpoint, cdpEndpoint: cliOptions.cdpEndpoint,
}, },
@ -131,7 +131,7 @@ async function loadConfig(configFile: string | undefined): Promise<Config> {
} }
} }
async function createUserDataDir(browserName: 'chromium' | 'firefox' | 'webkit') { async function createUserDataDir(options: { browserName: 'chromium' | 'firefox' | 'webkit', channel: string | undefined }) {
let cacheDirectory: string; let cacheDirectory: string;
if (process.platform === 'linux') if (process.platform === 'linux')
cacheDirectory = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache'); cacheDirectory = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');
@ -141,7 +141,7 @@ async function createUserDataDir(browserName: 'chromium' | 'firefox' | 'webkit')
cacheDirectory = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'); cacheDirectory = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
else else
throw new Error('Unsupported platform: ' + process.platform); throw new Error('Unsupported platform: ' + process.platform);
const result = path.join(cacheDirectory, 'ms-playwright', `mcp-${browserName}-profile`); const result = path.join(cacheDirectory, 'ms-playwright', `mcp-${options.channel ?? options.browserName}-profile`);
await fs.promises.mkdir(result, { recursive: true }); await fs.promises.mkdir(result, { recursive: true });
return result; return result;
} }