From 6315098104ff80f8be6d5ae812835b4b4079582e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 13 Aug 2019 17:15:52 +0200 Subject: [PATCH] modules: Do not fail build on errors in theme.toml Fixes #6162 --- hugolib/hugo_modules_test.go | 11 +++++++++-- modules/collect.go | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go index 58244049e..826f5f1e5 100644 --- a/hugolib/hugo_modules_test.go +++ b/hugolib/hugo_modules_test.go @@ -349,7 +349,8 @@ path="ok" path="incompat1" [[module.imports]] path="incompat2" - +[[module.imports]] +path="incompat3" `) @@ -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() @@ -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)) } diff --git a/modules/collect.go b/modules/collect.go index 9a18f5579..87f2720c1 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -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 {