Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/grunt-bootlint.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tasks
diff options
context:
space:
mode:
authorZac Echola <zac.echola@gmail.com>2014-07-26 11:04:31 +0400
committerZac Echola <zac.echola@gmail.com>2014-07-26 11:04:31 +0400
commit79b358c6770b22e30ca29426d04d77b3986ad0e4 (patch)
treec9e9b4ab2a0ece848d7bb3fc26519b8e39378a05 /tasks
parentc3437edcbceeec4215b9ab40aadbdb19d78ce388 (diff)
really basic thing so far.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/bootlint.js54
1 files changed, 36 insertions, 18 deletions
diff --git a/tasks/bootlint.js b/tasks/bootlint.js
index a8f00aa..5819c97 100644
--- a/tasks/bootlint.js
+++ b/tasks/bootlint.js
@@ -9,41 +9,59 @@
'use strict';
module.exports = function(grunt) {
+ var bootlint = require('../node_modules/bootlint/src/bootlint'); // Explicit since the search algo fails on the bootlint directory structure
+ var colors = require('colors');
+
+ colors.setTheme({
+ ok: 'green',
+ error: 'red',
+ warning: 'yellow'
+ });
+
+ var msg = {
+ start: 'Validation started for '.ok,
+ ok: 'Validation successful!'.ok,
+ error: 'Error:'.error,
+ done: 'All Done!'.bold.ok
+ };
+
+ var totalErrCount = 0;
- // Please see the Grunt documentation for more information regarding task
- // creation: http://gruntjs.com/creating-tasks
grunt.registerMultiTask('bootlint', 'An HTML linter for Bootstrap projects', function() {
- // Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
- punctuation: '.',
- separator: ', '
+ stoponerror: false
});
// Iterate over all specified file groups.
this.files.forEach(function(f) {
- // Concat specified files.
- var src = f.src.filter(function(filepath) {
- // Warn on and remove invalid source files (if nonull was set).
+
+ f.src.filter(function(filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
- }).map(function(filepath) {
- // Read file source.
- return grunt.file.read(filepath);
- }).join(grunt.util.normalizelf(options.separator));
- // Handle options.
- src += options.punctuation;
+ })
+ .forEach(function(filepath) {
+ var src = grunt.file.read(filepath);
+
+ var errs = bootlint.lintHtml(src);
+ totalErrCount += errs.length;
- // Write the destination file.
- grunt.file.write(f.dest, src);
+ errs.forEach(function (msg) {
+ grunt.log.warn(filepath + ':', msg.error);
+ if (options.stoponerror) return;
+ });
+ });
- // Print a success message.
- grunt.log.writeln('File "' + f.dest + '" created.');
+ if (totalErrCount > 0) {
+ grunt.log.warn(totalErrCount + ' lint errors found.');
+ } else {
+ grunt.log.writeln(msg.done);
+ }
});
});