mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Search current directory for config file by default
As of 2015-08-16, Viper no longer searches the CWD for config file by default to avoid unintended surprises, but Hugo relies on the original behaviour. Fixed by calling viper.AddConfigPath(".") at the appropriate place. See https://github.com/spf13/viper/issues/73 for more information. Fixes #1363
This commit is contained in:
parent
dac9c0dae6
commit
4047ca5c3c
1 changed files with 6 additions and 1 deletions
|
@ -165,7 +165,12 @@ func LoadDefaultSettings() {
|
|||
// InitializeConfig initializes a config file with sensible default configuration flags.
|
||||
func InitializeConfig() {
|
||||
viper.SetConfigFile(CfgFile)
|
||||
viper.AddConfigPath(Source)
|
||||
// See https://github.com/spf13/viper/issues/73#issuecomment-126970794
|
||||
if Source == "" {
|
||||
viper.AddConfigPath(".")
|
||||
} else {
|
||||
viper.AddConfigPath(Source)
|
||||
}
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
jww.ERROR.Println("Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details")
|
||||
|
|
Loading…
Reference in a new issue