Normalize the per-run temp dir (absolute and cwd-relative forms) so text snapshots are stable.
(text: string, tempDir: string)
| 46 | |
| 47 | /** Normalize the per-run temp dir (absolute and cwd-relative forms) so text snapshots are stable. */ |
| 48 | function withStableTmpPaths(text: string, tempDir: string): string { |
| 49 | // Replace the cwd-relative form first: the absolute tempDir is a substring of it, so |
| 50 | // replacing the absolute form first would leave a machine-dependent `../..` prefix behind. |
| 51 | const relTmp = relative(process.cwd(), tempDir) |
| 52 | return text.split(relTmp).join('<tmp>').split(tempDir).join('<tmp>').split(sep).join('/') |
| 53 | } |
| 54 | |
| 55 | describe('lint command', () => { |
| 56 | let program: Command |