From 3a5ee0d2d6e344b12efc7a97354ec3480c4c578b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 15 Feb 2021 11:11:34 +0100 Subject: [PATCH] modules: Allow absolute paths for any modules resolved via project replacement Fixes #8240 --- modules/collect.go | 2 +- modules/config.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/collect.go b/modules/collect.go index eb7e0d0000a..4de51258b1e 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -276,7 +276,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool // Fall back to project/themes/ if moduleDir == "" { var err error - moduleDir, err = c.createThemeDirname(modulePath, owner.projectMod) + moduleDir, err = c.createThemeDirname(modulePath, owner.projectMod || moduleImport.pathProjectReplaced) if err != nil { c.err = err return nil, nil diff --git a/modules/config.go b/modules/config.go index d56f3834395..106becc6091 100644 --- a/modules/config.go +++ b/modules/config.go @@ -237,6 +237,7 @@ func decodeConfig(cfg config.Provider, pathReplacements map[string]string) (Conf for i, imp := range c.Imports { if newImp, found := c.replacementsMap[imp.Path]; found { imp.Path = newImp + imp.pathProjectReplaced = true c.Imports[i] = imp } } @@ -355,12 +356,13 @@ func (v HugoVersion) IsValid() bool { } type Import struct { - Path string // Module path - IgnoreConfig bool // Ignore any config in config.toml (will still folow imports). - IgnoreImports bool // Do not follow any configured imports. - NoVendor bool // Never vendor this import (only allowed in main project). - Disable bool // Turn off this module. - Mounts []Mount + Path string // Module path + pathProjectReplaced bool // Set when Path is replaced in project config. + IgnoreConfig bool // Ignore any config in config.toml (will still folow imports). + IgnoreImports bool // Do not follow any configured imports. + NoVendor bool // Never vendor this import (only allowed in main project). + Disable bool // Turn off this module. + Mounts []Mount } type Mount struct {