import { dirname, join } from "jsr:@std/path/"; import { WalkEntry, walkSync } from "jsr:@std/fs/walk"; const ROOT = ; const DIR_SKIP_LIST = [ "/node_modules/", "/testdata/", "/tests/", "/.github/", "/bench", "/tsc", ]; const tsFiles = Deno.readTextFileSync("./ts_files.txt").split("\n"); const tsDirs = tsFiles.map((f) => dirname(f)).filter(shouldSkip).sort().reduce( (prev: string[], curr) => { if (prev.indexOf(curr) < 0) prev.push(curr); return prev; }, [], ); console.log(`| Folder | Throws | Status | PR |`); console.log(`| --- | --- | --- | --- |`); for (const dir of tsDirs) { const errors = await countErrors(dir); if (errors === 0) { console.log(`| ${dir} | ${errors} | ✅ | No obvious problems found|`); } else { console.log(`| ${dir} | ${errors} | ⛔| |`); } } function shouldSkip(dir: string): boolean { for (const skip of DIR_SKIP_LIST) { if (dir.includes(skip)) return false; } return !(dir === "."); } function countErrors(path: string): number { let errors = 0; const paths = walkSync(join(ROOT, path), { maxDepth: 1 }) .map(( f: WalkEntry, ) => f.path); for (const file of paths) { if (file.endsWith(".ts") || file.endsWith(".js")) { errors += countErrorsInFile(file); } } return errors; } function countErrorsInFile(path: string): number { const content = Deno.readTextFileSync(path).split("\n"); let errors = 0; for (const line of content) { if (line.includes("throw")) { errors++; } } return errors; }