Skip to content

Commit

Permalink
Merge pull request jacobstr#10 from Dalton001/master
Browse files Browse the repository at this point in the history
fix for using absolute path when root path set
  • Loading branch information
jacobstr committed Feb 3, 2016
2 parents f1d489f + e6dd07b commit 1f51067
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions confer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"fmt"
"path"
"path/filepath"
"reflect"
"strings"
"time"
"reflect"

"github.com/kr/pretty"
"github.com/spf13/cast"
Expand Down Expand Up @@ -231,10 +231,10 @@ func (manager *Config) ReadPaths(paths ...string) error {
for _, base_path := range paths {
var final_path string

if filepath.IsAbs(base_path) == false {
if !filepath.IsAbs(base_path) {
final_path = path.Join(manager.rootPath, base_path)
} else {
final_path = path.Join(manager.rootPath, base_path)
final_path = base_path
}

loaded, err = reader.ReadFile(final_path)
Expand Down
7 changes: 7 additions & 0 deletions confer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ func TestSpec(t *testing.T) {
So(config.GetStringMap("app"), ShouldResemble, application_yaml)
})

Convey("Absolute Path With Root Set", func() {
config.SetRootPath("test/fixtures")
currentDir, _ := os.Getwd()
config.ReadPaths(currentDir + "/test/fixtures/application.yaml")
So(config.GetStringMap("app"), ShouldResemble, application_yaml)
})

Convey("Multiple Paths", func() {
Convey("With A Missing File", func() {
config.ReadPaths("test/fixtures/application.yaml", "test/fixtures/missing.yaml")
Expand Down

0 comments on commit 1f51067

Please sign in to comment.