update to consistently use filepath instead of path and add looking in os.Getwd() for the config file to fix finding the config file in Windows issue

This commit is contained in:
Joel Scoble 2014-11-05 18:23:02 -06:00
parent 77144270da
commit 22f85e27c4

View file

@ -25,7 +25,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"path/filepath" "path/filepath"
"reflect" "reflect"
"runtime" "runtime"
@ -650,10 +649,10 @@ func searchInPath(in string) (filename string) {
jww.DEBUG.Println("Searching for config in ", in) jww.DEBUG.Println("Searching for config in ", in)
for _, ext := range SupportedExts { for _, ext := range SupportedExts {
jww.DEBUG.Println("Checking for", path.Join(in, configName+"."+ext)) jww.DEBUG.Println("Checking for", filepath.Join(in, configName+"."+ext))
if b, _ := exists(path.Join(in, configName+"."+ext)); b { if b, _ := exists(filepath.Join(in, configName+"."+ext)); b {
jww.DEBUG.Println("Found: ", path.Join(in, configName+"."+ext)) jww.DEBUG.Println("Found: ", filepath.Join(in, configName+"."+ext))
return path.Join(in, configName+"."+ext) return filepath.Join(in, configName+"."+ext)
} }
} }
@ -669,13 +668,19 @@ func findConfigFile() (string, error) {
return file, nil return file, nil
} }
} }
cwd, _ := findCWD()
cwd, _ := findCWD()
file := searchInPath(cwd) file := searchInPath(cwd)
if file != "" { if file != "" {
return file, nil return file, nil
} }
// try the current working directory
wd, _ := os.Getwd()
file = searchInPath(wd)
if file != "" {
return file, nil
}
return "", fmt.Errorf("config file not found in: %s", configPaths) return "", fmt.Errorf("config file not found in: %s", configPaths)
} }