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

Function moduleConfigDigest

src/resolution/index.ts:367–383  ·  view source on GitHub ↗

* A digest of what resolution reads from one config file: a go.mod's module * path, a tsconfig / jsconfig's `extends`, `baseUrl` and `paths`, what a Cargo * manifest declares (see `cargoManifestFields`), the include directories a * compile database names. Not of its bytes: a dependency bump, a `s

(abs: string, projectRoot: string)

Source from the content-addressed store, hash-verified

365 * every one.
366 */
367function moduleConfigDigest(abs: string, projectRoot: string): string {
368 const file = path.basename(abs);
369 // A codegraph.json counts for its `webRoot` alone, which places a PHP
370 // include of `$_SERVER['DOCUMENT_ROOT'] . '/x.php'` (#3298). One that sets
371 // none reads as no file, so writing one to `exclude` a folder, or a snapshot
372 // from before it counted, re-opens nothing.
373 if (file === PROJECT_CONFIG_FILENAME) {
374 const webRoot = loadWebRoot(path.dirname(abs));
375 return webRoot === null ? 'absent' : createHash('sha256').update(`webRoot=${webRoot}`).digest('hex').slice(0, 16);
376 }
377 const read = file === 'go.mod' ? loadGoModule(path.dirname(abs))?.modulePath ?? ''
378 : file === 'Cargo.toml' ? cargoManifestDigestText(abs)
379 : file === 'compile_commands.json' ? (readCompileDbIncludeDirs(abs, projectRoot) ?? []).join('\n')
380 : file === 'package.json' ? packageJsonMainOf(abs)
381 : aliasConfigFields(abs) ?? '';
382 return createHash('sha256').update(read).digest('hex').slice(0, 16);
383}
384
385/**
386 * A package.json as an object, read past a byte order mark; null when it is

Callers 1

moduleConfigEntryFunction · 0.85

Calls 8

loadWebRootFunction · 0.90
loadGoModuleFunction · 0.90
readCompileDbIncludeDirsFunction · 0.90
aliasConfigFieldsFunction · 0.90
cargoManifestDigestTextFunction · 0.85
packageJsonMainOfFunction · 0.85
updateMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected