Fix config loading for "hugo mod init"
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Jun 2021 10:03:43 +0000 (12:03 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 27 Jun 2021 10:03:43 +0000 (12:03 +0200)
commit923dd9d1c1f649142f3f377109318b07e0f44d5d
treea55ad5b934aa2f8d5a9594ce9a022fca3bc1e545
parentd9bdd37d35ccd436b4dd470ef99efa372a6a086b
Fix config loading for "hugo mod init"

We have some commands that will continue even if the config loading fails (e.g. because a module can not be found). In Hugo 0.84.0 we introduced a new `_merge` flag that we removed once the configuration was loaded. But we did not do that in error situations, leading to failures in some situations.

This commit fixes that by making sure the configuration is always cleaned before return, even in error situations.

Fixes #8697
hugolib/config.go