mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-27 00:52:27 +08:00
chore: use import.meta.resolve to lookup Playwright (#337)
This commit is contained in:
parent
d8a59e0d0d
commit
200cf737bb
@ -20,8 +20,7 @@ import path from 'path';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { defineTool } from './tool.js';
|
import { defineTool } from './tool.js';
|
||||||
|
|
||||||
import { createRequire } from 'node:module';
|
import { fileURLToPath } from 'node:url';
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
const install = defineTool({
|
const install = defineTool({
|
||||||
capability: 'install',
|
capability: 'install',
|
||||||
@ -33,8 +32,9 @@ const install = defineTool({
|
|||||||
|
|
||||||
handle: async context => {
|
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?.launchOptions.browserName ?? 'chrome';
|
||||||
const cli = path.join(require.resolve('playwright/package.json'), '..', 'cli.js');
|
const cliUrl = import.meta.resolve('playwright/package.json');
|
||||||
const child = fork(cli, ['install', channel], {
|
const cliPath = fileURLToPath(path.join(cliUrl, '..', 'cli.js'));
|
||||||
|
const child = fork(cliPath, ['install', channel], {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
});
|
});
|
||||||
const output: string[] = [];
|
const output: string[] = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user