diff options
author | Zac Echola <zac.echola@gmail.com> | 2014-07-26 08:48:19 +0400 |
---|---|---|
committer | Zac Echola <zac.echola@gmail.com> | 2014-07-26 08:48:19 +0400 |
commit | f52415bdb2b1569bbfc5a09e1133d48a5cbd0c86 (patch) | |
tree | 22201d396add6b35c821b52c2cb9cceed2fa5c13 /tasks |
:seedling:
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/bootlint.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tasks/bootlint.js b/tasks/bootlint.js new file mode 100644 index 0000000..a8f00aa --- /dev/null +++ b/tasks/bootlint.js @@ -0,0 +1,50 @@ +/* + * grunt-bootlint + * https://github.com/zacechola/grunt-bootlint + * + * Copyright (c) 2014 Zac Echola + * Licensed under the MIT license. + */ + +'use strict'; + +module.exports = function(grunt) { + + // 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: ', ' + }); + + // 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). + 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; + + // Write the destination file. + grunt.file.write(f.dest, src); + + // Print a success message. + grunt.log.writeln('File "' + f.dest + '" created.'); + }); + }); + +}; |