diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-07-30 13:35:16 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-07-31 12:10:05 +0200 |
commit | 36220851e4ed7fc3fa78aa250d001d5f922210e7 (patch) | |
tree | 730a02b3326b711cb18b4203b3cd530e753c0d17 /modules | |
parent | 53ade40ba47e73d0505b1685538b525f291b6e08 (diff) | |
download | hugo-36220851e4ed7fc3fa78aa250d001d5f922210e7.tar.gz hugo-36220851e4ed7fc3fa78aa250d001d5f922210e7.zip |
Fix self-mounts on the main project
Fixes #6143
Diffstat (limited to 'modules')
-rw-r--r-- | modules/collect.go | 32 | ||||
-rw-r--r-- | modules/config.go | 3 |
2 files changed, 21 insertions, 14 deletions
diff --git a/modules/collect.go b/modules/collect.go index 9f3eb99f1..5ba7f74e2 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -305,21 +305,25 @@ func (c *collector) addAndRecurse(owner *moduleAdapter, disabled bool) error { func (c *collector) applyMounts(moduleImport Import, mod *moduleAdapter) error { mounts := moduleImport.Mounts - if !mod.projectMod && len(mounts) == 0 { - modConfig := mod.Config() + modConfig := mod.Config() + + if len(mounts) == 0 { + // Mounts not defined by the import. mounts = modConfig.Mounts - if len(mounts) == 0 { - // Create default mount points for every component folder that - // exists in the module. - for _, componentFolder := range files.ComponentFolders { - sourceDir := filepath.Join(mod.Dir(), componentFolder) - _, err := c.fs.Stat(sourceDir) - if err == nil { - mounts = append(mounts, Mount{ - Source: componentFolder, - Target: componentFolder, - }) - } + + } + + if !mod.projectMod && len(mounts) == 0 { + // Create default mount points for every component folder that + // exists in the module. + for _, componentFolder := range files.ComponentFolders { + sourceDir := filepath.Join(mod.Dir(), componentFolder) + _, err := c.fs.Stat(sourceDir) + if err == nil { + mounts = append(mounts, Mount{ + Source: componentFolder, + Target: componentFolder, + }) } } } diff --git a/modules/config.go b/modules/config.go index 122fd6c55..163bc7049 100644 --- a/modules/config.go +++ b/modules/config.go @@ -171,6 +171,9 @@ func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error { mounts = append(mounts, Mount{Source: dirKey.component, Target: dirKey.component}) } + // Prepend the mounts from configuration. + mounts = append(moda.mounts, mounts...) + // Remove duplicates seen := make(map[string]bool) tmp := mounts[:0] |