Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

adding showallerrors option #37

Merged
merged 1 commit into from
Dec 31, 2014
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
25 changes: 25 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ module.exports = function(grunt) {
]
}
},
showallerrors: {
options: {
showallerrors: true,
},
files: {
'tmp/stoponwarning': [
'test/fixtures/missing-doctype.html',
'test/fixtures/missing-charset.html',
'test/fixtures/cols-redundant.html',
]
}
},
showallerrorswithstop: {
options: {
showallerrors: true,
stoponwarning: true,
},
files: {
'tmp/stoponwarning': [
'test/fixtures/missing-doctype.html',
'test/fixtures/missing-charset.html',
'test/fixtures/cols-redundant.html',
]
}
},
stoponboth: {
options: {
stoponwarning: true,
Expand Down
13 changes: 9 additions & 4 deletions tasks/bootlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function(grunt) {
var options = this.options({
stoponerror: false,
stoponwarning: false,
showallerrors: false,
relaxerror: []
});

Expand Down Expand Up @@ -53,14 +54,16 @@ module.exports = function(grunt) {
});

}

if (!output) {
grunt.log.warn(filepath + ":", lintId, lint.message);
totalErrCount++;
}

console.log((isError && options.stoponerror) || (isWarning && options.stoponwarning));
if ((isError && options.stoponerror) || (isWarning && options.stoponwarning)) {
grunt.fail.warn('Too many bootlint errors.');
if (!options.showallerrors) {
if ((isError && options.stoponerror) || (isWarning && options.stoponwarning)) {
grunt.fail.warn('Too many bootlint errors.');
}
}

};
Expand All @@ -69,9 +72,11 @@ module.exports = function(grunt) {
totalFileCount++;
});

if (totalErrCount > 0) {
if (totalErrCount > 0 && !options.showallerrors) {
grunt.log.writeln().fail(totalErrCount + " lint error(s) found across " + totalFileCount + " file(s).");
grunt.log.writeln().fail('For details, look up the lint problem IDs in the Bootlint wiki: https://github.com/twbs/bootlint/wiki');
} else if (totalErrCount > 0 && options.showallerrors) {
grunt.fail.warn(totalErrCount + " lint error(s) found across " + totalFileCount + " file(s). ");
} else {
grunt.log.ok(totalFileCount + ' file(s) lint free.');
}
Expand Down
22 changes: 22 additions & 0 deletions test/bootlint_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ exports.bootlint = {
test.done();
});
},
showallerrors: function(test) {
test.expect(1);
grunt.util.spawn({
grunt: true,
args: ['bootlint:showallerrors', '--no-color'],
}, function(err, result) {
test.ok(result.stdout.indexOf("8 lint error(s) found across 3 file(s). Use --force to continue.") >= 0,
'Should show all errors before hard fail.');
test.done();
});
},
showallerrorswithstop: function(test) {
test.expect(1);
grunt.util.spawn({
grunt: true,
args: ['bootlint:showallerrorswithstop', '--no-color'],
}, function(err, result) {
test.ok(result.stdout.indexOf("8 lint error(s) found across 3 file(s). Use --force to continue.") >= 0,
'Should show all errors before hard fail even if stopon* is set.');
test.done();
});
},
pass: function(test) {
test.expect(1);
grunt.util.spawn({
Expand Down