Skip to content

Commit

Permalink
GetUsedConfigSubDir() returns absolute path (normalized)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Aug 8, 2019
1 parent a8a76bd commit cf91d05
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions options.watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func GetUsedConfigFile() string {
return usedConfigFile
}

// GetUsedConfigSubDir returns the sub-directory `conf.d` of config files
// GetUsedConfigSubDir returns the sub-directory `conf.d` of config files.
// Note that it be always normalized now.
// Sometimes it might be empty string ("") if `conf.d` have not been found.
func GetUsedConfigSubDir() string {
return usedConfigSubDir
}
Expand Down Expand Up @@ -95,13 +97,14 @@ func (s *Options) LoadConfigFile(file string) (err error) {
return
}

err = filepath.Walk(usedConfigSubDir, s.visit)

usedConfigSubDir, err = filepath.Abs(usedConfigSubDir)
if err == nil {
s.watchConfigDir(usedConfigSubDir)
err = filepath.Walk(usedConfigSubDir, s.visit)
if err == nil {
s.watchConfigDir(usedConfigSubDir)
}
// log.Fatalf("ERROR: filepath.Walk() returned %v\n", err)
}
// log.Fatalf("ERROR: filepath.Walk() returned %v\n", err)

return
}

Expand Down

0 comments on commit cf91d05

Please sign in to comment.