Skip to content

Commit 8eb162a

Browse files
committed
Add Args.SilenceDeprecations option
1 parent 0aa345d commit 8eb162a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Diff for: options.go

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ type Args struct {
136136
// Additional file paths to uses to resolve imports.
137137
IncludePaths []string
138138

139+
// Deprecation IDs to silence, e.g. "import".
140+
SilenceDeprecations []string
141+
139142
sassOutputStyle embeddedsass.OutputStyle
140143
sassSourceSyntax embeddedsass.Syntax
141144

Diff for: transpiler.go

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func (t *Transpiler) Execute(args Args) (Result, error) {
216216
},
217217
SourceMap: args.EnableSourceMap,
218218
SourceMapIncludeSources: args.SourceMapIncludeSources,
219+
SilenceDeprecation: args.SilenceDeprecations,
219220
},
220221
}
221222

Diff for: transpiler_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,42 @@ div { p { color: $moo; } }`
196196
c.Assert(result.CSS, qt.Equals, "content{color:#ccc}div p{color:#f442d1}")
197197
}
198198

199+
func TestSilenceDeprecations(t *testing.T) {
200+
dir1 := t.TempDir()
201+
colors := filepath.Join(dir1, "_colors.scss")
202+
203+
os.WriteFile(colors, []byte(`
204+
$moo: #f442d1 !default;
205+
`), 0o644)
206+
207+
c := qt.New(t)
208+
src := `
209+
@import "colors";
210+
div { p { color: $moo; } }`
211+
212+
var loggedImportDeprecation bool
213+
transpiler, clean := newTestTranspiler(c, godartsass.Options{
214+
LogEventHandler: func(e godartsass.LogEvent) {
215+
if e.DeprecationType == "import" {
216+
loggedImportDeprecation = true
217+
}
218+
},
219+
})
220+
defer clean()
221+
222+
result, err := transpiler.Execute(
223+
godartsass.Args{
224+
Source: src,
225+
OutputStyle: godartsass.OutputStyleCompressed,
226+
IncludePaths: []string{dir1},
227+
SilenceDeprecations: []string{"import"},
228+
},
229+
)
230+
c.Assert(err, qt.IsNil)
231+
c.Assert(loggedImportDeprecation, qt.IsFalse)
232+
c.Assert(result.CSS, qt.Equals, "div p{color:#f442d1}")
233+
}
234+
199235
func TestTranspilerParallel(t *testing.T) {
200236
c := qt.New(t)
201237
transpiler, clean := newTestTranspiler(c, godartsass.Options{})

0 commit comments

Comments
 (0)