| 34 | const repos: string[] = []; |
| 35 | |
| 36 | async function walk(dir: string, depth: number): Promise<void> { |
| 37 | if (existsSync(join(dir, '.git'))) { |
| 38 | repos.push(dir); |
| 39 | return; |
| 40 | } |
| 41 | if (depth >= maxDepth) { |
| 42 | return; |
| 43 | } |
| 44 | let entries; |
| 45 | try { |
| 46 | entries = await readdir(dir, { withFileTypes: true }); |
| 47 | } catch { |
| 48 | return; |
| 49 | } |
| 50 | for (const entry of entries) { |
| 51 | if (!entry.isDirectory()) { |
| 52 | continue; |
| 53 | } |
| 54 | if (entry.name.startsWith('.')) { |
| 55 | continue; |
| 56 | } |
| 57 | if (SKIP_DIRS.has(entry.name)) { |
| 58 | continue; |
| 59 | } |
| 60 | await walk(join(dir, entry.name), depth + 1); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | await walk(root, 0); |
| 65 | return repos.sort(); |