fix(config): default to 'karma.yaml' config file

If config.file is not set try loading 'karma.yaml' from current directory. This is the documented behaviour and it used to work before, got broken when config.file was modified to accept a full path instead of just the file name

Fixes #261
This commit is contained in:
Łukasz Mierzwa
2018-11-22 22:45:43 +00:00
parent ed25cdbde6
commit 13dfae617c

View File

@@ -3,6 +3,7 @@ package config
import (
"bufio"
"bytes"
"os"
"strings"
"time"
@@ -106,6 +107,12 @@ func (config *configSchema) Read() {
v.SetConfigType("yaml")
configFile := v.GetString("config.file")
// if config file is not set then try loading karma.yaml from current directory
if configFile == "" {
if _, err = os.Stat("karma.yaml"); !os.IsNotExist(err) {
configFile = "karma.yaml"
}
}
if configFile != "" {
log.Infof("Reading configuration file %s", configFile)
v.SetConfigFile(configFile)