modules: Do not fail build on errors in theme.toml
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 13 Aug 2019 15:15:52 +0000 (17:15 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 13 Aug 2019 16:09:11 +0000 (18:09 +0200)
Fixes #6162

hugolib/hugo_modules_test.go
modules/collect.go

index 58244049ea6e8871981168db59cb3335632f7427..826f5f1e5e862656b66cbb3b0def07633d4c45de 100644 (file)
@@ -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))
 
 }
 
index 9a18f5579c8113398aedbc7585d5a9be506ce0f5..87f2720c1f1ae9ce17b0e2e4552e01fcca0f6210 100644 (file)
@@ -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 {