Skip to content

Commit

Permalink
modules: Do not fail build on errors in theme.toml
Browse files Browse the repository at this point in the history
Fixes #6162
  • Loading branch information
bep committed Aug 13, 2019
1 parent b64617f commit 6315098
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions hugolib/hugo_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ path="ok"
path="incompat1"
[[module.imports]]
path="incompat2"
[[module.imports]]
path="incompat3"
`)

Expand All @@ -368,6 +369,12 @@ max = "0.45.0"
b.WithSourceFile("themes/incompat2/theme.toml", `
min_version = "5.0.0"
`)

// Issue 6162
b.WithSourceFile("themes/incompat3/theme.toml", `
min_version = 0.55.0
`)

logger := loggers.NewWarningLogger()
Expand All @@ -377,7 +384,7 @@ min_version = "5.0.0"

c := qt.New(t)

c.Assert(logger.WarnCounter.Count(), qt.Equals, uint64(2))
c.Assert(logger.WarnCounter.Count(), qt.Equals, uint64(3))

}

Expand Down
5 changes: 3 additions & 2 deletions modules/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,10 @@ func (c *collector) applyThemeConfig(tc *moduleAdapter) error {
}
themeCfg, err = metadecoders.Default.UnmarshalToMap(data, metadecoders.TOML)
if err != nil {
return errors.Wrapf(err, "failed to read module config for %q in %q", tc.Path(), themeTOML)
c.logger.WARN.Printf("Failed to read module config for %q in %q: %s", tc.Path(), themeTOML, err)
} else {
maps.ToLower(themeCfg)
}
maps.ToLower(themeCfg)
}

if hasConfig {
Expand Down

0 comments on commit 6315098

Please sign in to comment.