mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
Fix handling of --contentDir etc. flag
We need to revisit the commands package re globals and tests, but this should fix the init order of flags and languages. Fixes #4589
This commit is contained in:
@@ -54,7 +54,7 @@ func LoadConfigDefault(fs afero.Fs) (*viper.Viper, error) {
|
||||
|
||||
// LoadConfig loads Hugo configuration into a new Viper and then adds
|
||||
// a set of defaults.
|
||||
func LoadConfig(d ConfigSourceDescriptor) (*viper.Viper, []string, error) {
|
||||
func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (*viper.Viper, []string, error) {
|
||||
var configFiles []string
|
||||
|
||||
fs := d.Fs
|
||||
@@ -108,6 +108,14 @@ func LoadConfig(d ConfigSourceDescriptor) (*viper.Viper, []string, error) {
|
||||
configFiles = append(configFiles, themeConfigFile)
|
||||
}
|
||||
|
||||
// We create languages based on the settings, so we need to make sure that
|
||||
// all configuration is loaded/set before doing that.
|
||||
for _, d := range doWithConfig {
|
||||
if err := d(v); err != nil {
|
||||
return v, configFiles, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := loadLanguageSettings(v, nil); err != nil {
|
||||
return v, configFiles, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user