chore: allow specifying output dir (#285)

Ref: https://github.com/microsoft/playwright-mcp/issues/279
This commit is contained in:
Pavel Feldman
2025-04-28 16:35:33 -07:00
committed by GitHub
parent 6e76d5e550
commit 697a69a8c2
6 changed files with 52 additions and 11 deletions

View File

@@ -14,14 +14,11 @@
* limitations under the License.
*/
import os from 'os';
import path from 'path';
import { z } from 'zod';
import { defineTool } from './tool';
import { sanitizeForFilePath } from './utils';
import * as javascript from '../javascript';
import { outputFile } from '../config';
const pdf = defineTool({
capability: 'pdf',
@@ -34,7 +31,7 @@ const pdf = defineTool({
handle: async context => {
const tab = context.currentTabOrDie();
const fileName = path.join(os.tmpdir(), sanitizeForFilePath(`page-${new Date().toISOString()}`)) + '.pdf';
const fileName = await outputFile(context.config, `page-${new Date().toISOString()}'.pdf'`);
const code = [
`// Save page as ${fileName}`,