* The directories three or more levels down that hold indexed JS/TS code or a * directory that does, never inside `node_modules`: shallowest first, at most * MAX_DEEP_PROBES of them. Sorted within a level, so the sample does * not depend on the order the files come in. Extraction lists th
(files: readonly string[])
| 99 | * from its own list which frameworks run. |
| 100 | */ |
| 101 | function deepScriptDirectories(files: readonly string[]): string[] { |
| 102 | // levels[n]: the directories n levels down (`a/b/c/` is 3). |
| 103 | const levels: Set<string>[] = []; |
| 104 | for (const file of files) { |
| 105 | if (!SCRIPT_FILE.test(file) || file.includes('node_modules')) continue; |
| 106 | let depth = 0; |
| 107 | for (let slash = file.indexOf('/'); slash >= 0; slash = file.indexOf('/', slash + 1)) { |
| 108 | if (++depth >= 3) (levels[depth] ??= new Set()).add(file.slice(0, slash + 1)); |
| 109 | } |
| 110 | } |
| 111 | const dirs: string[] = []; |
| 112 | for (let depth = 3; depth < levels.length; depth++) { |
| 113 | for (const dir of [...(levels[depth] ?? [])].sort()) { |
| 114 | if (dirs.length === MAX_DEEP_PROBES) return dirs; |
| 115 | dirs.push(dir); |
| 116 | } |
| 117 | } |
| 118 | return dirs; |
| 119 | } |
| 120 | |
| 121 | /** True when any of `deps` is declared anywhere the project's manifests are read. */ |
| 122 | export function dependsOn(context: ResolutionContext, ...deps: string[]): boolean { |
no test coverage detected