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
```
- `%USERPROFILE%\AppData\Local\ms-playwright\mcp-chromium-profile` on Windows
- `~/Library/Caches/ms-playwright/mcp-chromium-profile` on macOS
- `~/.cache/ms-playwright/mcp-chromium-profile` on Linux
- `%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile` on Windows
- `~/Library/Caches/ms-playwright/mcp-{channel}-profile` on macOS
- `~/.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.

View File

@ -96,7 +96,7 @@ export async function configFromCLIOptions(cliOptions: CLIOptions): Promise<Conf
return {
browser: {
browserName,
userDataDir: cliOptions.userDataDir ?? await createUserDataDir(browserName),
userDataDir: cliOptions.userDataDir ?? await createUserDataDir({ browserName, channel }),
launchOptions,
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;
if (process.platform === 'linux')
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');
else
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 });
return result;
}