chore: use import.meta.resolve to lookup Playwright (#337)

This commit is contained in:
Pavel Feldman 2025-05-03 14:38:58 -07:00 committed by GitHub
parent d8a59e0d0d
commit 200cf737bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,8 +20,7 @@ import path from 'path';
import { z } from 'zod';
import { defineTool } from './tool.js';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
import { fileURLToPath } from 'node:url';
const install = defineTool({
capability: 'install',
@ -33,8 +32,9 @@ const install = defineTool({
handle: async context => {
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 child = fork(cli, ['install', channel], {
const cliUrl = import.meta.resolve('playwright/package.json');
const cliPath = fileURLToPath(path.join(cliUrl, '..', 'cli.js'));
const child = fork(cliPath, ['install', channel], {
stdio: 'pipe',
});
const output: string[] = [];