Also, resolve any workspace file relative to the workingDir.
Fixes #10553
{multiSiteYAMLConfigTemplate, "yml"},
{multiSiteJSONConfigTemplate, "json"},
} {
+ config := config
t.Run(config.suffix, func(t *testing.T) {
t.Parallel()
doTestMultiSitesBuild(t, config.content, config.suffix)
}
for i, test := range tests {
+ i := i
test := test
t.Run(fmt.Sprintf("%s-%d", test.file, i), func(t *testing.T) {
t.Parallel()
"github.com/mitchellh/mapstructure"
)
+const WorkspaceDisabled = "off"
+
var DefaultModuleConfig = Config{
// Default to direct, which means "git clone" and similar. We
// treated as private.
Private: "*.*",
+ // Default is no workspace resolution.
+ Workspace: WorkspaceDisabled,
+
// A list of replacement directives mapping a module path to a directory
// or a theme component in the themes folder.
// Note that this will turn the component into a traditional theme component
c.Mounts[i] = mnt
}
+ if c.Workspace == "" {
+ c.Workspace = WorkspaceDisabled
+ }
+ if c.Workspace != WorkspaceDisabled {
+ c.Workspace = filepath.Clean(c.Workspace)
+ if !filepath.IsAbs(c.Workspace) {
+ workingDir := cfg.GetString("workingDir")
+ c.Workspace = filepath.Join(workingDir, c.Workspace)
+ }
+ }
}
if themeSet {
// Configures GOPRIVATE.
Private string
- // Set the workspace file to use, e.g. hugo.work.
- // Enables Go "Workspace" mode.
+ // Defaults to "off".
+ // Set to a work file, e.g. hugo.work, to enable Go "Workspace" mode.
+ // Can be relative to the working directory or absolute.
// Requires Go 1.18+
// See https://tip.golang.org/doc/go1.18
Workspace string
c.Run("Basic", func(c *qt.C) {
tomlConfig := `
+workingDir = "/src/project"
[module]
-
+workspace = "hugo.work"
[module.hugoVersion]
min = "0.54.2"
max = "0.199.0"
extended = true
-
[[module.mounts]]
source="src/project/blog"
target="content/blog"
c.Assert(hv.IsValid(), qt.Equals, true)
}
+ c.Assert(mcfg.Workspace, qt.Equals, "/src/project/hugo.work")
+
c.Assert(len(mcfg.Mounts), qt.Equals, 1)
c.Assert(len(mcfg.Imports), qt.Equals, 1)
imp := mcfg.Imports[0]
c.Assert(imp.Mounts[1].Source, qt.Equals, "src/markdown/blog")
c.Assert(imp.Mounts[1].Target, qt.Equals, "content/blog")
c.Assert(imp.Mounts[1].Lang, qt.Equals, "en")
+
})
c.Run("Replacements", func(c *qt.C) {