(
root: string,
opts: { maxDepth?: number; max?: number } = {},
)
| 210 | * never turns into a full-tree crawl on a large repo. |
| 211 | */ |
| 212 | export function findIndexedSubprojectRoots( |
| 213 | root: string, |
| 214 | opts: { maxDepth?: number; max?: number } = {}, |
| 215 | ): string[] { |
| 216 | const maxDepth = opts.maxDepth ?? 4; |
| 217 | const max = opts.max ?? 64; |
| 218 | const out: string[] = []; |
| 219 | const walk = (dir: string, depth: number): void => { |
| 220 | if (out.length >= max || depth > maxDepth) return; |
| 221 | let entries: fs.Dirent[]; |
| 222 | try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; } |
| 223 | for (const e of entries) { |
| 224 | if (out.length >= max) return; |
| 225 | if (!e.isDirectory()) continue; |
| 226 | if (e.name.startsWith('.') || SUBPROJECT_SCAN_SKIP.has(e.name)) continue; |
| 227 | const child = path.join(dir, e.name); |
| 228 | if (isInitialized(child)) { out.push(child); continue; } // don't descend into an indexed project |
| 229 | walk(child, depth + 1); |
| 230 | } |
| 231 | }; |
| 232 | walk(root, 1); |
| 233 | return out; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * English structural keywords, matched with `\b` word boundaries so a keyword |
no test coverage detected