modules: Allow absolute paths for any modules resolved via project replacement
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 15 Feb 2021 10:11:34 +0000 (11:11 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 15 Feb 2021 10:11:34 +0000 (11:11 +0100)
Fixes #8240

modules/collect.go
modules/config.go

index eb7e0d0000ae6423129bf87b7878d76a700e6491..4de51258b1e9a5bf454e772d8c7583e615b621ba 100644 (file)
@@ -276,7 +276,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool
                        // Fall back to project/themes/<mymodule>
                        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
index d56f38343951b6e71bd47cc484428d44f24c75ae..106becc60916a016d70f35851f0d5b21792ffbb6 100644 (file)
@@ -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 {