Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add failHard option; fixes #21 #22

Merged
merged 1 commit into from
Dec 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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