Skip to content

Commit ff8a595

Browse files
committed
feat: Allow suppressing of printing the report on the console
Add a "quite" flag to the task options, false by default.
1 parent 9a92d69 commit ff8a595

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ module.exports = function (grunt) {
4949
src: 'test/work/missing.html'
5050
},
5151
incomplete: {
52+
options: {
53+
quiet: true
54+
},
5255
src: 'test/work/incomplete.html'
5356
},
5457
minimal: {

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ or integrate it to your build sequence in `Gruntfile.js`:
5454
grunt.registerTask('default', ['tidy-html5', ...]);
5555
```
5656

57+
Warnings about invalid parts of the HTML markup will be logged on the console,
58+
if the `quiet` mode is not enabled. If there are any, unless the task
59+
execution is `force`d, the task will make Grunt fail.
60+
5761
## Customizing
5862

5963
Default behaviour of the task can be tweaked by the task options; these
@@ -65,6 +69,7 @@ grunt.initConfig({
6569
task: {
6670
options: {
6771
force: false,
72+
quiet: false,
6873
ignoreMissing: false,
6974
tidyOptions: {}
7075
},
@@ -83,6 +88,13 @@ Default: `false`
8388
Suppresses reporting the failure to Grunt and thus stopping execution
8489
of further tasks, if set to `true`.
8590

91+
#### quiet
92+
Type: `Boolean`
93+
Default: `false`
94+
95+
Suppresses printing of errors and warnings about problems found in input
96+
files on the console. if set to `true`.
97+
8698
#### ignoreMissing
8799
Type: `Boolean`
88100
Default: `false`

tasks/tidy-html5.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ module.exports = function (grunt) {
1717
const done = this.async()
1818
const options = this.options({
1919
force: false,
20+
quiet: false,
2021
ignoreMissing: false,
2122
tidyOptions: {}
2223
})
2324
const force = options.force
25+
const quiet = options.quiet
2426
const ignoreMissing = options.ignoreMissing
2527
const tidyOptions = options.tidyOptions
2628
const files = this.files
@@ -82,7 +84,9 @@ module.exports = function (grunt) {
8284
.then(function (result) {
8385
const errors = result.errlog
8486
if (errors.length) {
85-
grunt.log.write(errors)
87+
if (!quiet) {
88+
grunt.log.write(errors)
89+
}
8690
++failed
8791
}
8892
})

0 commit comments

Comments
 (0)