shithub: hugo

Download patch

ref: 6315098104ff80f8be6d5ae812835b4b4079582e
parent: b64617fe4f90da030bcf4a9c5a4913393ce96b14
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Tue Aug 13 13:15:52 EDT 2019

modules: Do not fail build on errors in theme.toml

Fixes #6162

--- a/hugolib/hugo_modules_test.go
+++ b/hugolib/hugo_modules_test.go
@@ -349,8 +349,9 @@
 path="incompat1"
 [[module.imports]]
 path="incompat2"
+[[module.imports]]
+path="incompat3"
 
-
 `)
 
 	b.WithSourceFile("themes/ok/data/ok.toml", `title = "OK"`)
@@ -370,6 +371,12 @@
 
 `)
 
+	// Issue 6162
+	b.WithSourceFile("themes/incompat3/theme.toml", `
+min_version = 0.55.0
+
+`)
+
 	logger := loggers.NewWarningLogger()
 	b.WithLogger(logger)
 
@@ -377,7 +384,7 @@
 
 	c := qt.New(t)
 
-	c.Assert(logger.WarnCounter.Count(), qt.Equals, uint64(2))
+	c.Assert(logger.WarnCounter.Count(), qt.Equals, uint64(3))
 
 }
 
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -412,9 +412,10 @@
 		}
 		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 {