diff --git a/helpers/file_utils.go b/helpers/file_utils.go index 97a5696..c06595a 100644 --- a/helpers/file_utils.go +++ b/helpers/file_utils.go @@ -15,6 +15,7 @@ package helpers import ( + "errors" "os" "path/filepath" @@ -52,3 +53,17 @@ func Exists(path string) bool { } return false } + +// FindFileDir returns the path of the +func FindFileDir(file string) (string, error) { + wd, err := os.Getwd() + if err != nil { + return "", nil + } + for path := wd; path != "."; path = filepath.Dir(path) { + if Exists(filepath.Join(path, file)) { + return path, nil + } + } + return "", errors.New("directory not found") +}