| 1 | // Fails when a lesson links to a file, symbol or ADR the repository no longer has, so lessons cannot drift silently from the code. |
| 2 | import { existsSync, globSync |
| 3 | import path from "node:path |
| 4 | |
| 5 | const app = path |
| 6 | const root = path |
| 7 | const lessons = globSync |
| 8 | |
| 9 | const problems: string |
| 10 | let checked = 0 |
| 11 | for (const lesson |
| 12 | const text = |
| 13 | for (const [, |
| 14 | /<Source path="([^"]+) |
| 15 | )) { |
| 16 | checked++; |
| 17 | const target = |
| 18 | if (!existsSync(target |
| 19 | else if ( |
| 20 | symbol && |
| 21 | statSync(target).isFile |
| 22 | !readFileSync(target, |
| 23 | ) |
| 24 | problems.push(`${ |
| 25 | } |
| 26 | for (const [, |
| 27 | checked++; |
| 28 | if (!existsSync(path |
| 29 | problems.push(`${ |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if (problems.length > |
| 34 | console.error(problems |
| 35 | process.exit(1) |
| 36 | } |
| 37 | console.log(`${checked |