Skip to content

Commit 308a50c

Browse files
committed
Merge branch 'add-quiet-dart-sass-support'
2 parents a20df25 + b519a8b commit 308a50c

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ compileSass {
7171
// (Default is to not to watch, compile once and terminate)
7272
watch ()
7373
74+
// Prevent sass to emit warnings
75+
// (Default is to emit them)
76+
quiet ()
77+
7478
// Source map style:
7579
// - file: output source map in a separate file (default)
7680
// - embed: embed source map in CSS

src/functionalTest/java/io/miret/etienne/gradle/sass/SassGradlePluginFunctionalTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,22 @@ void should_create_file_source_map_with_relative_urls () throws IOException {
290290
));
291291
}
292292

293+
@Test
294+
void should_be_quiet () throws IOException {
295+
Path out = createExecutable();
296+
297+
GradleRunner.create ()
298+
.withPluginClasspath ()
299+
.withArguments ("quiet")
300+
.withProjectDir (projectDir.toFile ())
301+
.build();
302+
303+
assertThat (out).hasContent (String.format (
304+
"sass --style=expanded --quiet --source-map-urls=relative %1$s/src/main/sass:%1$s/build/sass",
305+
projectDir.toRealPath ()
306+
));
307+
}
308+
293309
private Path createExecutable () throws IOException {
294310
Path out = projectDir.resolve ("build/out");
295311
Path sassDir = projectDir.resolve (".gradle/sass/some.specific.version/dart-sass");

src/functionalTest/resources/io/miret/etienne/gradle/sass/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ task watch (type: CompileSass) {
2424
watch ()
2525
}
2626

27+
task quiet (type: CompileSass) {
28+
quiet ()
29+
}
30+
2731
task compileNoCharset (type: CompileSass) {
2832
noCharset ()
2933
}

src/main/java/io/miret/etienne/gradle/sass/CompileSass.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ enum SourceMapUrls {
6262
@Getter (onMethod_ = {@Input})
6363
private boolean errorCss = true;
6464

65+
@Getter (onMethod_ = {@Input})
66+
private boolean quiet = false;
67+
6568
@Setter
6669
@Getter (onMethod_ = {@Input})
6770
private SourceMap sourceMap = SourceMap.file;
@@ -111,6 +114,10 @@ public void watch () {
111114
watch = true;
112115
}
113116

117+
public void quiet () {
118+
quiet = true;
119+
}
120+
114121
@Internal
115122
public Style getExpanded () {
116123
return Style.expanded;
@@ -168,6 +175,7 @@ public void compileSass () {
168175
compileSassWorkParameters.getWatch ().set (watch);
169176
compileSassWorkParameters.getCharset ().set (charset);
170177
compileSassWorkParameters.getErrorCss ().set (errorCss);
178+
compileSassWorkParameters.getQuiet ().set (quiet);
171179
});
172180
}
173181

src/main/java/io/miret/etienne/gradle/sass/CompileSassWorkAction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public void execute() {
3838
if (!parameters.getErrorCss().get()) {
3939
args.add ("--no-error-css");
4040
}
41+
if (parameters.getQuiet().get()) {
42+
args.add ("--quiet");
43+
}
4144
CompileSass.SourceMap sourceMap = parameters.getSourceMap().get();
4245
switch (sourceMap) {
4346
case none:

src/main/java/io/miret/etienne/gradle/sass/CompileSassWorkParameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ public interface CompileSassWorkParameters extends WorkParameters {
1919
Property<Boolean> getWatch();
2020
Property<Boolean> getCharset();
2121
Property<Boolean> getErrorCss();
22+
Property<Boolean> getQuiet();
2223
}

0 commit comments

Comments
 (0)