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

Function tryWithExtensions

src/resolution/import-resolver.ts:1585–1593  ·  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

1583 * (indexedSpelling).
1584 */
1585function tryWithExtensions(basePath: string, language: Language, context: ResolutionContext): string | null {
1586 for (const ext of EXTENSION_RESOLUTION[language] || []) {
1587 const candidate = indexedSpelling(basePath + ext, language);
1588 if (context.fileExists(candidate)) return candidate;
1589 }
1590 const asIs = indexedSpelling(basePath, language);
1591 if (context.fileExists(asIs)) return asIs;
1592 return findSourceForEmittedSpecifier(asIs, language, context);
1593}
1594
1595/**
1596 * 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