MCPcopy Index your code
hub / github.com/microsoft/typescript-go / tryGetAnyFileFromPath

Function tryGetAnyFileFromPath

internal/modulespecifiers/util.go:194–223  ·  view source on GitHub ↗
(host ModuleSpecifierGenerationHost, path string)

Source from the content-addressed store, hash-verified

192}
193
194func tryGetAnyFileFromPath(host ModuleSpecifierGenerationHost, path string) bool {
195 // !!! TODO: shouldn't this use readdir instead of fileexists for perf?
196 // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
197 extGroups := tsoptions.GetSupportedExtensions(
198 &core.CompilerOptions{
199 AllowJs: core.TSTrue,
200 },
201 []tsoptions.FileExtensionInfo{
202 {
203 Extension: "node",
204 IsMixedContent: false,
205 ScriptKind: core.ScriptKindExternal,
206 },
207 {
208 Extension: "json",
209 IsMixedContent: false,
210 ScriptKind: core.ScriptKindJSON,
211 },
212 },
213 )
214 for _, exts := range extGroups {
215 for _, e := range exts {
216 fullPath := path + e
217 if host.FileExists(tspath.GetNormalizedAbsolutePath(fullPath, host.GetCurrentDirectory())) {
218 return true
219 }
220 }
221 }
222 return false
223}
224
225func getPathsRelativeToRootDirs(path string, rootDirs []string, useCaseSensitiveFileNames bool) []string {
226 var results []string

Callers 1

processEndingFunction · 0.85

Calls 4

GetSupportedExtensionsFunction · 0.92
FileExistsMethod · 0.65
GetCurrentDirectoryMethod · 0.65

Tested by

no test coverage detected