@@ -642,3 +642,65 @@ T1: {{ $r.Content }}
642642 b .AssertLogContains ("! Dart Sass: DEPRECATED [import]" )
643643 b .AssertFileContent ("public/index.html" , `moo{color:#fff}` )
644644}
645+
646+ func TestSilenceDependencyDeprecations (t * testing.T ) {
647+ t .Parallel ()
648+
649+ files := `
650+ -- hugo.toml --
651+ disableKinds = ['page','rss','section','sitemap','taxonomy','term']
652+ -- layouts/index.html --
653+ {{ $opts := dict
654+ "transpiler" "dartsass"
655+ "outputStyle" "compressed"
656+ "includePaths" (slice "node_modules")
657+ KVPAIR
658+ }}
659+ {{ (resources.Get "sass/main.scss" | css.Sass $opts).Content }}
660+ -- assets/sass/main.scss --
661+ @use "sass:color";
662+ @use "foo/deprecated.scss";
663+ h3 { color: rgb(color.channel(#ccc, "red", $space: rgb), 0, 0); }
664+ // COMMENT
665+ -- node_modules/foo/deprecated.scss --
666+ @use "sass:color";
667+ h1 { color: rgb(color.channel(#eee, "red", $space: rgb), 0, 0); }
668+ h2 { color: rgb(color.red(#ddd), 0, 0); } // deprecated
669+ `
670+
671+ expectedCSS := "h1{color:#e00}h2{color:#d00}h3{color:#c00}"
672+
673+ // Do not silence dependency deprecation warnings (default).
674+ f := strings .ReplaceAll (files , "KVPAIR" , "" )
675+ b := hugolib .Test (t , f , hugolib .TestOptWarn (), hugolib .TestOptOsFs ())
676+ b .AssertFileContent ("public/index.html" , expectedCSS )
677+ b .AssertLogContains (
678+ "WARN Dart Sass: DEPRECATED [color-functions]" ,
679+ "color.red() is deprecated" ,
680+ )
681+
682+ // Do not silence dependency deprecation warnings (explicit).
683+ f = strings .ReplaceAll (files , "KVPAIR" , `"silenceDependencyDeprecations" false` )
684+ b = hugolib .Test (t , f , hugolib .TestOptWarn (), hugolib .TestOptOsFs ())
685+ b .AssertFileContent ("public/index.html" , expectedCSS )
686+ b .AssertLogContains (
687+ "WARN Dart Sass: DEPRECATED [color-functions]" ,
688+ "color.red() is deprecated" ,
689+ )
690+
691+ // Silence dependency deprecation warnings.
692+ f = strings .ReplaceAll (files , "KVPAIR" , `"silenceDependencyDeprecations" true` )
693+ b = hugolib .Test (t , f , hugolib .TestOptWarn (), hugolib .TestOptOsFs ())
694+ b .AssertFileContent ("public/index.html" , expectedCSS )
695+ b .AssertLogContains ("! WARN" )
696+
697+ // Make sure that we are not silencing non-dependency deprecation warnings.
698+ f = strings .ReplaceAll (files , "KVPAIR" , `"silenceDependencyDeprecations" true` )
699+ f = strings .ReplaceAll (f , "// COMMENT" , "h4 { color: rgb(0, color.green(#bbb), 0); }" )
700+ b = hugolib .Test (t , f , hugolib .TestOptWarn (), hugolib .TestOptOsFs ())
701+ b .AssertFileContent ("public/index.html" , expectedCSS + "h4{color:#0b0}" )
702+ b .AssertLogContains (
703+ "WARN Dart Sass: DEPRECATED [color-functions]" ,
704+ "color.green() is deprecated" ,
705+ )
706+ }
0 commit comments