MCPcopy Index your code
hub / github.com/go-task/task / SearchAll

Function SearchAll

internal/fsext/fs.go:94–115  ·  view source on GitHub ↗

SearchAll looks for files with the given possible filenames using the given entrypoint and directory. If the entrypoint is set, it checks if the entrypoint matches a file or if it matches a directory containing one of the possible filenames and add it to a list of matches. It then walks up the file

(entrypoint, dir string, possibleFilenames []string)

Source from the content-addressed store, hash-verified

92// starting there. If matches are found, the absolute path to each file is added
93// to the list and returned.
94func SearchAll(entrypoint, dir string, possibleFilenames []string) ([]string, error) {
95 var err error
96 var entrypoints []string
97 if entrypoint != "" {
98 entrypoint, err = SearchPath(entrypoint, possibleFilenames)
99 if err != nil {
100 return nil, err
101 }
102 entrypoints = append(entrypoints, entrypoint)
103 }
104 if dir == "" {
105 dir, err = os.Getwd()
106 if err != nil {
107 return nil, err
108 }
109 }
110 paths, err := SearchNPathRecursively(dir, possibleFilenames, -1)
111 // The call to SearchNPathRecursively is ambiguous and may return
112 // os.ErrPermission if its search ends, however it may have still
113 // returned valid paths. Caller may choose to ignore that error.
114 return append(entrypoints, paths...), err
115}
116
117// SearchPath will check if a file at the given path exists or not. If it does,
118// it will return the path to it. If it does not, it will search for any files

Callers 1

GetConfigFunction · 0.92

Calls 2

SearchPathFunction · 0.85
SearchNPathRecursivelyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…