Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/hugolib/config.go b/hugolib/config.go
index a0ce98042..3e3700433 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -63,6 +63,10 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
var configFiles []string
l := configLoader{ConfigSourceDescriptor: d, cfg: config.New()}
+ // Make sure we always do this, even in error situations,
+ // as we have commands (e.g. "hugo mod init") that will
+ // use a partial configuration to do its job.
+ defer l.deleteMergeStrategies()
for _, name := range d.configFilenames() {
var filename string
@@ -125,10 +129,7 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
collectHook := func(m *modules.ModulesConfig) error {
// We don't need the merge strategy configuration anymore,
// remove it so it doesn't accidentaly show up in other settings.
- l.cfg.WalkParams(func(params ...config.KeyParams) bool {
- params[len(params)-1].Params.DeleteMergeStrategy()
- return false
- })
+ l.deleteMergeStrategies()
if err := l.loadLanguageSettings(nil); err != nil {
return err
@@ -461,6 +462,13 @@ func (l configLoader) loadConfig(configName string) (string, error) {
return filename, nil
}
+func (l configLoader) deleteMergeStrategies() {
+ l.cfg.WalkParams(func(params ...config.KeyParams) bool {
+ params[len(params)-1].Params.DeleteMergeStrategy()
+ return false
+ })
+}
+
func (l configLoader) loadLanguageSettings(oldLangs langs.Languages) error {
_, err := langs.LoadLanguageSettings(l.cfg, oldLangs)
return err