Skip to content

Commit

Permalink
Fix hugo mod vendor for modules with hugo.toml
Browse files Browse the repository at this point in the history
Fixes #11221
  • Loading branch information
bep committed Jul 8, 2023
1 parent 6019953 commit 0f921ac
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestUnfinished(t *testing.T) {

p := commonTestScriptsParam
p.Dir = "testscripts/unfinished"
//p.UpdateScripts = true

testscript.Run(t, p)
}
Expand Down
4 changes: 3 additions & 1 deletion modules/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions testscripts/commands/mod_vendor.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f921ac

Please sign in to comment.