diff options
107 files changed, 2115 insertions, 1016 deletions
diff --git a/cache/filecache/filecache_config.go b/cache/filecache/filecache_config.go index 0c6b569c1..801799e36 100644 --- a/cache/filecache/filecache_config.go +++ b/cache/filecache/filecache_config.go @@ -19,6 +19,8 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/common/maps" + "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/helpers" @@ -123,6 +125,9 @@ func DecodeConfig(fs afero.Fs, cfg config.Provider) (Configs, error) { _, isOsFs := fs.(*afero.OsFs) for k, v := range m { + if _, ok := v.(maps.Params); !ok { + continue + } cc := defaultCacheConfig dc := &mapstructure.DecoderConfig{ @@ -137,7 +142,7 @@ func DecodeConfig(fs afero.Fs, cfg config.Provider) (Configs, error) { } if err := decoder.Decode(v); err != nil { - return nil, err + return nil, errors.Wrap(err, "failed to decode filecache config") } if cc.Dir == "" { diff --git a/cache/filecache/filecache_config_test.go b/cache/filecache/filecache_config_test.go index cd1d2c82a..acc127e67 100644 --- a/cache/filecache/filecache_config_test.go +++ b/cache/filecache/filecache_config_test.go @@ -25,7 +25,6 @@ import ( "github.com/gohugoio/hugo/config" qt "github.com/frankban/quicktest" - "github.com/spf13/viper" ) func TestDecodeConfig(t *testing.T) { @@ -178,8 +177,8 @@ dir = "/" c.Assert(err, qt.Not(qt.IsNil)) } -func newTestConfig() *viper.Viper { - cfg := viper.New() +func newTestConfig() config.Provider { + cfg := config.New() cfg.Set("workingDir", filepath.FromSlash("/my/cool/hugoproject")) cfg.Set("contentDir", "content") cfg.Set("dataDir", "data") diff --git a/commands/commandeer.go b/commands/commandeer.go index 024651aad..06e27cf18 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -410,7 +410,5 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error { } config.Set("cacheDir", cacheDir) - cfg.Logger.Infoln("Using config file:", config.ConfigFileUsed()) - return nil } diff --git a/commands/commands_test.go b/commands/commands_test.go index a0eeb157b..99ffea48c 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -20,6 +20,8 @@ import ( "path/filepath" "testing" + "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/htesting" "github.com/spf13/afero" @@ -29,7 +31,6 @@ import ( "github.com/gohugoio/hugo/common/types" "github.com/spf13/cobra" - "github.com/spf13/viper" qt "github.com/frankban/quicktest" ) @@ -166,7 +167,7 @@ func TestFlags(t *testing.T) { name: "ignoreVendor as bool", args: []string{"server", "--ignoreVendor"}, check: func(c *qt.C, cmd *serverCmd) { - cfg := viper.New() + cfg := config.New() cmd.flagsToConfig(cfg) c.Assert(cfg.Get("ignoreVendor"), qt.Equals, true) }, @@ -176,7 +177,7 @@ func TestFlags(t *testing.T) { name: "ignoreVendorPaths", args: []string{"server", "--ignoreVendorPaths=github.com/**"}, check: func(c *qt.C, cmd *serverCmd) { - cfg := viper.New() + cfg := config.New() cmd.flagsToConfig(cfg) |