( content: string, fileName: string, baseDir: string = os.tmpdir(), )
| 570 | } |
| 571 | |
| 572 | export function createTempFile( |
| 573 | content: string, |
| 574 | fileName: string, |
| 575 | baseDir: string = os.tmpdir(), |
| 576 | ): { |
| 577 | path: string; |
| 578 | [Symbol.dispose]: () => void; |
| 579 | } { |
| 580 | const dirPath = fs.mkdtempSync( |
| 581 | path.join(baseDir, 'chrome-devtools-test-file-'), |
| 582 | ); |
| 583 | const filePath = path.join(dirPath, fileName); |
| 584 | fs.writeFileSync(filePath, content); |
| 585 | return { |
| 586 | path: filePath, |
| 587 | [Symbol.dispose](): void { |
| 588 | try { |
| 589 | fs.rmSync(dirPath, {recursive: true, force: true}); |
| 590 | } catch { |
| 591 | // ignore |
| 592 | } |
| 593 | }, |
| 594 | }; |
| 595 | } |
no outgoing calls
no test coverage detected