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

Function tryWithExtensions

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

1520 * (indexedSpelling).
1521 */
1522function tryWithExtensions(basePath: string, language: Language, context: ResolutionContext): string | null {
1523 for (const ext of EXTENSION_RESOLUTION[language] || []) {
1524 const candidate = indexedSpelling(basePath + ext, language);
1525 if (context.fileExists(candidate)) return candidate;
1526 }
1527 const asIs = indexedSpelling(basePath, language);
1528 if (context.fileExists(asIs)) return asIs;
1529 return findSourceForEmittedSpecifier(asIs, language, context);
1530}
1531
1532/**
1533 * 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