( dir: string, root: string = dir, )
| 44 | ); |
| 45 | |
| 46 | async function readAllFiles( |
| 47 | dir: string, |
| 48 | root: string = dir, |
| 49 | ): Promise<Array<{ path: string; content: string }>> { |
| 50 | const entries = await readdir(dir, { withFileTypes: true }); |
| 51 | const results: Array<{ path: string; content: string }> = []; |
| 52 | for (const entry of entries) { |
| 53 | const fullPath = join(dir, entry.name); |
| 54 | if (entry.isDirectory()) { |
| 55 | // Pass the original root down so paths are relative to the fixture root, |
| 56 | // not the current recursion level. |
| 57 | results.push(...(await readAllFiles(fullPath, root))); |
| 58 | } else { |
| 59 | results.push({ |
| 60 | path: relative(root, fullPath), |
| 61 | content: await readFile(fullPath, 'utf-8'), |
| 62 | }); |
| 63 | } |
| 64 | } |
| 65 | return results; |
| 66 | } |
| 67 | |
| 68 | function runAndLog( |
| 69 | files: Array<{ path: string; content: string }>, |
no test coverage detected