diff options
author | Zac Echola <zac.echola@so.mnscu.edu> | 2014-11-14 23:51:46 +0300 |
---|---|---|
committer | Zac Echola <zac.echola@so.mnscu.edu> | 2014-11-14 23:51:46 +0300 |
commit | 597c723490ca8652a7193b63a33bd9142d1c1bda (patch) | |
tree | 994ff32212a05a2f020d7d6c18c440d9709b0298 /tasks/bootlint.js | |
parent | 4304977365e7d092cc540dd557e66c25847440b9 (diff) |
add stoponwarning option
Diffstat (limited to 'tasks/bootlint.js')
-rw-r--r-- | tasks/bootlint.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tasks/bootlint.js b/tasks/bootlint.js index e6f7a83..0eb5eff 100644 --- a/tasks/bootlint.js +++ b/tasks/bootlint.js @@ -16,6 +16,7 @@ module.exports = function(grunt) { grunt.registerMultiTask('bootlint', 'An HTML linter for Bootstrap projects', function() { var options = this.options({ stoponerror: false, + stoponwarning: false, relaxerror: [] }); @@ -38,8 +39,11 @@ module.exports = function(grunt) { var src = grunt.file.read(filepath); var reporter = function (lint) { - var lintId = (lint.id[0] === 'E') ? chalk.bgGreen.white(lint.id) : chalk.bgRed.white(lint.id); + var isError = (lint.id[0] === 'E'); + var isWarning = (lint.id[0] === 'W'); + var lintId = (isError) ? chalk.bgGreen.white(lint.id) : chalk.bgRed.white(lint.id); var output = false; + if (lint.elements) { lint.elements.each(function (_, element) { var loc = element.startLocation; @@ -54,9 +58,11 @@ module.exports = function(grunt) { totalErrCount++; } - if (options.stoponerror) { + console.log((isError && options.stoponerror) || (isWarning && options.stoponwarning)); + if ((isError && options.stoponerror) || (isWarning && options.stoponwarning)) { grunt.fail.warn('Too many bootlint errors.'); } + }; bootlint.lintHtml(src, reporter, options.relaxerror); |