From a1fe552fc9e622a15010a94281f604eb85bebd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 21 Jan 2021 10:09:33 +0100 Subject: [PATCH] Fix nilpointer in js.Build error handling Fixes #8162 --- resources/resource_transformers/js/build.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/resource_transformers/js/build.go b/resources/resource_transformers/js/build.go index 0d70bdc337f..ee60aa502ec 100644 --- a/resources/resource_transformers/js/build.go +++ b/resources/resource_transformers/js/build.go @@ -14,7 +14,6 @@ package js import ( - "errors" "fmt" "io/ioutil" "os" @@ -22,6 +21,8 @@ import ( "regexp" "strings" + "github.com/pkg/errors" + "github.com/spf13/afero" "github.com/gohugoio/hugo/hugofs" @@ -108,6 +109,9 @@ func (t *buildTransformation) Transform(ctx *resources.ResourceTransformationCtx createErr := func(msg api.Message) error { loc := msg.Location + if loc == nil { + return errors.New(msg.Text) + } path := loc.File var (