MCPcopy Index your code
hub / github.com/nodejs/node / tryGetAnyFileFromPath

Function tryGetAnyFileFromPath

test/fixtures/snapshot/typescript.js:122601–122613  ·  view source on GitHub ↗
(host, path)

Source from the content-addressed store, hash-verified

122599 }
122600 }
122601 function tryGetAnyFileFromPath(host, path) {
122602 if (!host.fileExists)
122603 return;
122604 // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
122605 var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }]));
122606 for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
122607 var e = extensions_3[_i];
122608 var fullPath = path + e;
122609 if (host.fileExists(fullPath)) {
122610 return fullPath;
122611 }
122612 }
122613 }
122614 function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
122615 return ts.firstDefined(rootDirs, function (rootDir) {
122616 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected