0.1.2 • Published 8 years ago
grunt-remove-logging-calls v0.1.2
grunt-remove-logging-calls
About
This plugin removes/replaces all or any part of console logging statements from javascript code.
It handles complex cases like console.log('hello: ' + foo(), bar())
because it's based on the syntax tree given by Esprima.
Getting Started
This plugin requires Grunt. Install this plugin with the command:
npm install grunt-remove-logging-calls
Once the plugin has been installed, enable it inside the Gruntfile:
grunt.loadNpmTasks('grunt-remove-logging-calls');
Finally, add some configuration.
Configuration
grunt.initConfig({
// ...
removeLoggingCalls: {
// the files inside which you want to remove the console statements
files: ['src/**/*.js'],
options: {
// an array of method names to remove
methods: ['log', 'info', 'assert'],
// replacement strategy
strategy: function(consoleStatement) {
// comments console calls statements
return '/* ' + consoleStatement + '*/';
// return ''; // to remove
},
// when the logging statement is ended by a semicolon ';'
// include it in the 'consoleStatement' given to the strategy
removeSemicolonIfPossible: true
}
}
// ...
});