(path string)
| 102 | } |
| 103 | |
| 104 | func open(path string) (*Config, error) { |
| 105 | // First try the happy path by assuming that path is a directory |
| 106 | // containing a devbox.json. |
| 107 | cfg, err := searchDir(path) |
| 108 | if errors.Is(err, ErrNotFound) || errors.Is(err, errNotDirectory) { |
| 109 | // Try reading path directly as a config file. |
| 110 | slog.Debug("trying config file", "path", path) |
| 111 | cfg, err = readFromFile(path) |
| 112 | if errors.Is(err, errIsDirectory) { |
| 113 | return nil, ErrNotFound |
| 114 | } |
| 115 | } |
| 116 | return cfg, err |
| 117 | } |
| 118 | |
| 119 | // Find is like [Open] except it recursively searches up the directory tree, |
| 120 | // starting in path. It returns [ErrNotFound] if path is a valid directory and |
no test coverage detected