diff --git a/options.go b/options.go index bb70177..b995fda 100644 --- a/options.go +++ b/options.go @@ -136,6 +136,9 @@ type Args struct { // Additional file paths to uses to resolve imports. IncludePaths []string + // Deprecation IDs to silence, e.g. "import". + SilenceDeprecations []string + sassOutputStyle embeddedsass.OutputStyle sassSourceSyntax embeddedsass.Syntax diff --git a/transpiler.go b/transpiler.go index 483cf2d..db3f395 100644 --- a/transpiler.go +++ b/transpiler.go @@ -216,6 +216,7 @@ func (t *Transpiler) Execute(args Args) (Result, error) { }, SourceMap: args.EnableSourceMap, SourceMapIncludeSources: args.SourceMapIncludeSources, + SilenceDeprecation: args.SilenceDeprecations, }, } diff --git a/transpiler_test.go b/transpiler_test.go index 038a073..d5910de 100644 --- a/transpiler_test.go +++ b/transpiler_test.go @@ -196,6 +196,42 @@ div { p { color: $moo; } }` c.Assert(result.CSS, qt.Equals, "content{color:#ccc}div p{color:#f442d1}") } +func TestSilenceDeprecations(t *testing.T) { + dir1 := t.TempDir() + colors := filepath.Join(dir1, "_colors.scss") + + os.WriteFile(colors, []byte(` +$moo: #f442d1 !default; +`), 0o644) + + c := qt.New(t) + src := ` +@import "colors"; +div { p { color: $moo; } }` + + var loggedImportDeprecation bool + transpiler, clean := newTestTranspiler(c, godartsass.Options{ + LogEventHandler: func(e godartsass.LogEvent) { + if e.DeprecationType == "import" { + loggedImportDeprecation = true + } + }, + }) + defer clean() + + result, err := transpiler.Execute( + godartsass.Args{ + Source: src, + OutputStyle: godartsass.OutputStyleCompressed, + IncludePaths: []string{dir1}, + SilenceDeprecations: []string{"import"}, + }, + ) + c.Assert(err, qt.IsNil) + c.Assert(loggedImportDeprecation, qt.IsFalse) + c.Assert(result.CSS, qt.Equals, "div p{color:#f442d1}") +} + func TestTranspilerParallel(t *testing.T) { c := qt.New(t) transpiler, clean := newTestTranspiler(c, godartsass.Options{})