aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-11-21 09:48:54 +0100
committerBjørn Erik Pedersen <[email protected]>2024-11-21 20:00:36 +0100
commit8d017a60fb53b3ffb7b57f6c483fe92c3f2813cd (patch)
treec09fad1610e5ec78e49dd3b456ff558f516ba90c
parent8fcd3c148707d8cace2f375e537c30a821ea2516 (diff)
downloadhugo-8d017a60fb53b3ffb7b57f6c483fe92c3f2813cd.tar.gz
hugo-8d017a60fb53b3ffb7b57f6c483fe92c3f2813cd.zip
dartsass: Fix nilpointer on Close when Dart Sass isn't installed
Fixes #13076
-rw-r--r--resources/resource_transformers/cssjs/postcss_integration_test.go2
-rw-r--r--resources/resource_transformers/tocss/dartsass/client.go15
2 files changed, 10 insertions, 7 deletions
diff --git a/resources/resource_transformers/cssjs/postcss_integration_test.go b/resources/resource_transformers/cssjs/postcss_integration_test.go
index e8f52326c..8f2132789 100644
--- a/resources/resource_transformers/cssjs/postcss_integration_test.go
+++ b/resources/resource_transformers/cssjs/postcss_integration_test.go
@@ -70,7 +70,7 @@ hello:
other: "Bonjour"
-- layouts/index.html --
{{ $options := dict "inlineImports" true }}
-{{ $styles := resources.Get "css/styles.css" | resources.PostCSS $options }}
+{{ $styles := resources.Get "css/styles.css" | css.PostCSS $options }}
Styles RelPermalink: {{ $styles.RelPermalink }}
{{ $cssContent := $styles.Content }}
Styles Content: Len: {{ len $styles.Content }}|
diff --git a/resources/resource_transformers/tocss/dartsass/client.go b/resources/resource_transformers/tocss/dartsass/client.go
index 470c18b97..4ab958c01 100644
--- a/resources/resource_transformers/tocss/dartsass/client.go
+++ b/resources/resource_transformers/tocss/dartsass/client.go
@@ -44,7 +44,7 @@ const dartSassStdinPrefix = "hugostdin:"
func New(fs *filesystems.SourceFilesystem, rs *resources.Spec) (*Client, error) {
if !Supports() {
- return &Client{dartSassNotAvailable: true}, nil
+ return &Client{}, nil
}
if hugo.DartSassBinaryName == "" {
@@ -89,22 +89,25 @@ func New(fs *filesystems.SourceFilesystem, rs *resources.Spec) (*Client, error)
}
type Client struct {
- dartSassNotAvailable bool
- rs *resources.Spec
- sfs *filesystems.SourceFilesystem
- workFs afero.Fs
+ rs *resources.Spec
+ sfs *filesystems.SourceFilesystem
+ workFs afero.Fs
+ // This may be nil if Dart Sass is not available.
transpiler *godartsass.Transpiler
}
func (c *Client) ToCSS(res resources.ResourceTransformer, args map[string]any) (resource.Resource, error) {
- if c.dartSassNotAvailable {
+ if c.transpiler == nil {
return res.Transform(resources.NewFeatureNotAvailableTransformer(transformationName, args))
}
return res.Transform(&transform{c: c, optsm: args})
}
func (c *Client) Close() error {
+ if c.transpiler == nil {
+ return nil
+ }
return c.transpiler.Close()
}