MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / createTempFile

Function createTempFile

tests/utils.ts:629–652  ·  view source on GitHub ↗
(
  content: string,
  fileName: string,
  baseDir: string = os.tmpdir(),
)

Source from the content-addressed store, hash-verified

627}
628
629export function createTempFile(
630 content: string,
631 fileName: string,
632 baseDir: string = os.tmpdir(),
633): {
634 path: string;
635 [Symbol.dispose]: () => void;
636} {
637 const dirPath = fs.mkdtempSync(
638 path.join(baseDir, 'chrome-devtools-test-file-'),
639 );
640 const filePath = path.join(dirPath, fileName);
641 fs.writeFileSync(filePath, content);
642 return {
643 path: filePath,
644 [Symbol.dispose](): void {
645 try {
646 fs.rmSync(dirPath, {recursive: true, force: true});
647 } catch {
648 // ignore
649 }
650 },
651 };
652}
653
654export async function createDisposableTempFile(filename: string): Promise<{
655 path: string;

Callers 7

cli.test.tsFile · 0.85
McpServer.test.tsFile · 0.85
McpContext.test.tsFile · 0.85
input.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected