Commands/run: Try all suffixes for default config
This commit is contained in:
1 file changed
+8
-5
+8
-5
@@ -182,12 +182,15 @@ func getConfigFilePath(verbose bool) cmdarg.Arg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if workingDir, err := os.Getwd(); err == nil {
|
if workingDir, err := os.Getwd(); err == nil {
|
||||||
configFile := filepath.Join(workingDir, "config.json")
|
suffixes := []string{".json", ".jsonc", ".toml", ".yaml", ".yml"}
|
||||||
if fileExists(configFile) {
|
for _, suffix := range suffixes {
|
||||||
if verbose {
|
configFile := filepath.Join(workingDir, "config"+suffix)
|
||||||
log.Println("Using default config: ", configFile)
|
if fileExists(configFile) {
|
||||||
|
if verbose {
|
||||||
|
log.Println("Using default config: ", configFile)
|
||||||
|
}
|
||||||
|
return cmdarg.Arg{configFile}
|
||||||
}
|
}
|
||||||
return cmdarg.Arg{configFile}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user