Fix hugo mod vendor for modules with hugo.toml

Fixes #11221
This commit is contained in:
Bjørn Erik Pedersen 2023-07-08 12:25:53 +02:00
parent 6019953769
commit 0f921ace6f
3 changed files with 28 additions and 1 deletions

View file

@ -50,6 +50,7 @@ func TestUnfinished(t *testing.T) {
p := commonTestScriptsParam
p.Dir = "testscripts/unfinished"
//p.UpdateScripts = true
testscript.Run(t, p)
}

View file

@ -292,8 +292,10 @@ func (c *Client) Vendor() error {
}
}
// Also include any theme.toml or config.* files in the root.
// Also include any theme.toml or config.* or hugo.* files in the root.
configFiles, _ := afero.Glob(c.fs, filepath.Join(dir, "config.*"))
configFiles2, _ := afero.Glob(c.fs, filepath.Join(dir, "hugo.*"))
configFiles = append(configFiles, configFiles2...)
configFiles = append(configFiles, filepath.Join(dir, "theme.toml"))
for _, configFile := range configFiles {
if err := hugio.CopyFile(c.fs, configFile, filepath.Join(vendorDir, t.Path(), filepath.Base(configFile))); err != nil {

View file

@ -0,0 +1,24 @@
dostounix golden/vendor.txt
hugo mod vendor
cmp _vendor/modules.txt golden/vendor.txt
ls _vendor/github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml
stdout 'config.toml'
ls _vendor/github.com/gohugoio/hugo-mod-integrationtests/withhugotoml
stdout 'hugo.toml'
-- hugo.toml --
title = "Hugo Modules Test"
[module]
[[module.imports]]
path="github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml"
[[module.imports]]
path="github.com/gohugoio/hugo-mod-integrationtests/withhugotoml"
-- go.mod --
go 1.19
module github.com/gohugoio/testmod
-- golden/vendor.txt --
# github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml v1.0.0
# github.com/gohugoio/hugo-mod-integrationtests/withhugotoml v1.0.0