resolveProjectRoot returns the absolute path of the directory containing .taskmd.yaml, or cwd as fallback. Since initConfig() already walks up the directory tree to find the config, we just use the config location.
()
| 232 | // resolveProjectRoot returns the absolute path of the directory containing .taskmd.yaml, or cwd as fallback. |
| 233 | // Since initConfig() already walks up the directory tree to find the config, we just use the config location. |
| 234 | func resolveProjectRoot() string { |
| 235 | configFile := viper.ConfigFileUsed() |
| 236 | if configFile != "" { |
| 237 | abs, err := filepath.Abs(filepath.Dir(configFile)) |
| 238 | if err == nil { |
| 239 | return abs |
| 240 | } |
| 241 | return filepath.Dir(configFile) |
| 242 | } |
| 243 | |
| 244 | cwd, err := os.Getwd() |
| 245 | if err != nil { |
| 246 | return "." |
| 247 | } |
| 248 | return cwd |
| 249 | } |
no outgoing calls