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

Function tryWithExtensions

src/resolution/import-resolver.ts:1583–1591  ·  view source on GitHub ↗

* The file `basePath` names: with the language's extensions or index files, as * is, or as an emitted `.js` — each spelled as the index keys it * (indexedSpelling).

(basePath: string, language: Language, context: ResolutionContext)

Source from the content-addressed store, hash-verified

1581 * (indexedSpelling).
1582 */
1583function tryWithExtensions(basePath: string, language: Language, context: ResolutionContext): string | null {
1584 for (const ext of EXTENSION_RESOLUTION[language] || []) {
1585 const candidate = indexedSpelling(basePath + ext, language);
1586 if (context.fileExists(candidate)) return candidate;
1587 }
1588 const asIs = indexedSpelling(basePath, language);
1589 if (context.fileExists(asIs)) return asIs;
1590 return findSourceForEmittedSpecifier(asIs, language, context);
1591}
1592
1593/**
1594 * A path as the index keys its files. The alias, workspace and direct-path

Callers 2

tryWithExtFunction · 0.85
resolveFromOwnConfigFunction · 0.85

Calls 3

indexedSpellingFunction · 0.85
fileExistsMethod · 0.80

Tested by

no test coverage detected