| 25 | const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.output', '.next', '.nuxt', '.turbo']) |
| 26 | |
| 27 | async function findReadmes(dir: string): Promise<string[]> { |
| 28 | const entries = await readdir(dir, { withFileTypes: true }) |
| 29 | const result: string[] = [] |
| 30 | const subdirPromises: Promise<string[]>[] = [] |
| 31 | |
| 32 | for (const entry of entries) { |
| 33 | const fullPath = path.join(dir, entry.name) |
| 34 | |
| 35 | if (entry.isDirectory()) { |
| 36 | if (SKIP_DIRS.has(entry.name)) { |
| 37 | continue |
| 38 | } |
| 39 | |
| 40 | subdirPromises.push(findReadmes(fullPath)) |
| 41 | } |
| 42 | else if (entry.isFile() && entry.name === README_FILE_NAME) { |
| 43 | result.push(fullPath) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | const subResults = await Promise.all(subdirPromises) |
| 48 | return result.concat(...subResults) |
| 49 | } |
| 50 | |
| 51 | function withTracking(url: string): string { |
| 52 | try { |