Skip to content

Commit

Permalink
add a new task to remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
lordfriend committed Dec 4, 2014
1 parent 64357fb commit 6bea648
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tasks/remove-logging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* remove console.log for distribution files.
*/

var groundskeeper = require('groundskeeper');

module.exports = function(grunt) {

grunt.registerMultiTask('remove-logging', 'remove console.log for distribution files', function() {
this.files.forEach(function(file) {
file.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) {
var content = grunt.file.read(filepath);
var cleaner = groundskeeper();
cleaner.write(content);
grunt.file.write(file.dest, cleaner.toString());
})
})
})
};

0 comments on commit 6bea648

Please sign in to comment.