dartsass: Enable deprecation, @warn and @debug logging

* @warn and Sass deprecations are printed as WARN
* @debug is currently logged as INFO (needs the `--verbose` flag). We may adjust this if it gets too chatty.

Fixes #9683
This commit is contained in:
Bjørn Erik Pedersen
2022-03-17 17:22:34 +01:00
parent 64afb7ca51
commit 423594e03a
6 changed files with 66 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/dartsass"
jww "github.com/spf13/jwalterweatherman"
)
func TestTransformIncludePaths(t *testing.T) {
@@ -164,3 +165,34 @@ zoo {
b.AssertFileContent("public/index.html", `T1: moo{color:#ccc}boo{color:green}zoo{color:pink}`)
}
func TestTransformLogging(t *testing.T) {
if !dartsass.Supports() {
t.Skip()
}
files := `
-- assets/scss/main.scss --
@warn "foo";
@debug "bar";
-- config.toml --
disableKinds = ["term", "taxonomy", "section", "page"]
-- layouts/index.html --
{{ $cssOpts := (dict "transpiler" "dartsass" ) }}
{{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }}
T1: {{ $r.Content }}
`
b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: files,
NeedsOsFS: true,
LogLevel: jww.LevelInfo,
}).Build()
b.AssertLogMatches(`WARN.*Dart Sass: foo`)
b.AssertLogMatches(`INFO.*Dart Sass: .*assets.*main.scss:1:0: bar`)
}