MCPcopy Index your code
hub / github.com/jetify-com/devbox / Find

Function Find

internal/devconfig/config.go:125–140  ·  view source on GitHub ↗

Find is like [Open] except it recursively searches up the directory tree, starting in path. It returns [ErrNotFound] if path is a valid directory and neither it nor any of its parents contain a config file. Find stops searching as soon as it encounters a file with a well-known config name (such as

(path string)

Source from the content-addressed store, hash-verified

123// Find stops searching as soon as it encounters a file with a well-known config
124// name (such as devbox.json), even if that config fails to load.
125func Find(path string) (*Config, error) {
126 start := time.Now()
127 slog.Debug("searching for config file (including parent directories)", "path", path)
128
129 cfg, err := open(path)
130 if errors.Is(err, ErrNotFound) {
131 cfg, err = searchParentDirs(path)
132 }
133
134 if err == nil {
135 slog.Debug("config file found", "path", cfg.Root.AbsRootPath, "dur", time.Since(start))
136 } else {
137 slog.Error("config file search error", "err", err.Error(), "dur", time.Since(start))
138 }
139 return cfg, err
140}
141
142// searchDir looks for a config file in dir. It does not search parent
143// directories.

Callers 3

OpenFunction · 0.92
TestFindFunction · 0.85
TestFindErrorFunction · 0.85

Calls 4

openFunction · 0.85
searchParentDirsFunction · 0.85
IsMethod · 0.80
ErrorMethod · 0.45

Tested by 2

TestFindFunction · 0.68
TestFindErrorFunction · 0.68