Writes a fixture project with `files` (relative path → content) into a fresh temp dir.
(files: Record<string, string>)
| 201 | |
| 202 | /** Writes a fixture project with `files` (relative path → content) into a fresh temp dir. */ |
| 203 | async function createProject(files: Record<string, string>): Promise<void> { |
| 204 | tempDir = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'ngp-unchanged-test-'))); |
| 205 | tsconfigPath = path.join(tempDir, 'tsconfig.json'); |
| 206 | |
| 207 | const nodeModules = getOrCreateSyntheticNodeModules(); |
| 208 | if (nodeModules) { |
| 209 | await fs.symlink(nodeModules, path.join(tempDir, 'node_modules'), 'dir'); |
| 210 | } |
| 211 | |
| 212 | const tsconfig = {compilerOptions: {strict: true}, files: Object.keys(files)}; |
| 213 | await fs.writeFile(tsconfigPath, JSON.stringify(tsconfig)); |
| 214 | await Promise.all( |
| 215 | Object.entries(files).map(([name, content]) => |
| 216 | fs.writeFile(path.join(tempDir, name), content), |
| 217 | ), |
| 218 | ); |
| 219 | } |
| 220 | |
| 221 | const runNgp = (...args: string[]) => |
| 222 | execFileSync( |
no test coverage detected