(rootPath)
| 5 | import { pathExists, readJson, readText, relativePath } from "../lib/files.js"; |
| 6 | |
| 7 | async function findCoverageFiles(rootPath) { |
| 8 | const results = []; |
| 9 | const ignored = new Set([".git", "node_modules", ".venv", "venv", "__pycache__"]); |
| 10 | |
| 11 | async function visit(currentPath) { |
| 12 | const entries = await fs.readdir(currentPath, { withFileTypes: true }); |
| 13 | for (const entry of entries) { |
| 14 | const entryPath = path.join(currentPath, entry.name); |
| 15 | if (entry.isDirectory()) { |
| 16 | if (ignored.has(entry.name)) { |
| 17 | continue; |
| 18 | } |
| 19 | await visit(entryPath); |
| 20 | continue; |
| 21 | } |
| 22 | if ( |
| 23 | entry.isFile() && |
| 24 | ["lcov.info", "coverage.xml", "coverage-final.json", "coverage-summary.json"].includes(entry.name) |
| 25 | ) { |
| 26 | results.push(entryPath); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | await visit(rootPath); |
| 32 | return results.sort(); |
| 33 | } |
| 34 | |
| 35 | async function parseLcov(filePath) { |
| 36 | const text = await readText(filePath); |
no test coverage detected