Skip to content

Commit

Permalink
Merge pull request #22 from cvrebert/fail-hard
Browse files Browse the repository at this point in the history
add failHard option; fixes #21
  • Loading branch information
praveenvijayan committed Dec 17, 2013
2 parents 7927bf9 + be25864 commit 9ec373a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ Set `false` for autodetect or chose one of this options:
- ``windows-1256``
- ``windows-1257``

#### options.failHard
Type: `boolean` <br/>
Default value: `false`

If true, the task will fail at the end of its run if there were any validation errors that were not ignored via `options.relaxerror`.

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

Expand Down
7 changes: 7 additions & 0 deletions tasks/html_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = function(grunt) {
reportpath: "validation-report.json",
reset: false,
stoponerror: false,
failHard: false,
remotePath: false,
maxTry: 3,
relaxerror:[],
Expand Down Expand Up @@ -228,6 +229,12 @@ module.exports = function(grunt) {
grunt.file.write(options.reportpath, JSON.stringify(reportArry));
console.log("Validation report generated: ".green + options.reportpath);
}
if (options.failHard) {
var validationErrCount = reportArry.reduce(function (sum, report) { return sum + report.error.length; }, 0);
if (validationErrCount > 0) {
grunt.fail.warn(validationErrCount + " total unignored HTML validation error" + grunt.util.pluralize(validationErrCount, "/s") + ".");
}
}
done();
}

Expand Down

0 comments on commit 9ec373a

Please sign in to comment.