diff --git a/tasks/remove-logging.js b/tasks/remove-logging.js new file mode 100644 index 0000000..8216459 --- /dev/null +++ b/tasks/remove-logging.js @@ -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()); + }) + }) + }) +};