remove-logging.js 765 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * remove console.log for distribution files.
  3. */
  4. var groundskeeper = require('groundskeeper');
  5. module.exports = function(grunt) {
  6. grunt.registerMultiTask('remove-logging', 'remove console.log for distribution files', function() {
  7. this.files.forEach(function(file) {
  8. file.src.filter(function(filepath) {
  9. if(!grunt.file.exists(filepath)) {
  10. grunt.log.warn('Source file "' + filepath + '" not found.');
  11. return false;
  12. } else {
  13. return true;
  14. }
  15. })
  16. .map(function(filepath) {
  17. var content = grunt.file.read(filepath);
  18. var cleaner = groundskeeper();
  19. cleaner.write(content);
  20. grunt.file.write(file.dest, cleaner.toString());
  21. })
  22. })
  23. })
  24. };