-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a new task to remove console.log
- Loading branch information
1 parent
64357fb
commit 6bea648
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
}) | ||
}) | ||
}) | ||
}; |