( content: string, fileName: string, baseDir: string = os.tmpdir(), )
| 627 | } |
| 628 | |
| 629 | export 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 | |
| 654 | export async function createDisposableTempFile(filename: string): Promise<{ |
| 655 | path: string; |
no outgoing calls
no test coverage detected