MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / deepScriptDirectories

Function deepScriptDirectories

src/resolution/frameworks/package-deps.ts:101–119  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

99 * from its own list which frameworks run.
100 */
101function 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. */
122export function dependsOn(context: ResolutionContext, ...deps: string[]): boolean {

Callers 1

declaredDependenciesFunction · 0.85

Calls 2

pushMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected