MCPcopy
hub / github.com/esm-dev/esm.sh / lookupClosestFile

Function lookupClosestFile

cli/utils.go:60–81  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

58}
59
60func lookupClosestFile(name string) (filename string, exists bool, err error) {
61 cwd, err := os.Getwd()
62 if err != nil {
63 return "", false, err
64 }
65 dir := cwd
66 for {
67 indexHtml := filepath.Join(dir, name)
68 fi, err := os.Stat(indexHtml)
69 if err == nil && !fi.IsDir() {
70 return indexHtml, true, nil
71 }
72 if err != nil && os.IsExist(err) {
73 return "", false, err
74 }
75 dir = filepath.Dir(dir)
76 if dir == "/" || (os.PathSeparator == '\\' && len(dir) <= 3) {
77 break
78 }
79 }
80 return filepath.Join(cwd, name), false, nil
81}

Callers 2

tidyFunction · 0.85
updateImportMapFunction · 0.85

Calls 1

StatMethod · 0.65

Tested by

no test coverage detected