strip-debug 
Strip console
, alert
, and debugger
statements from JavaScript code
Useful for making sure you didn't leave any logging in production code.
Also available as gulp/grunt/broccoli plugins.
Install
$ npm install --save strip-debug
Usage
var stripDebug = require('strip-debug');
stripDebug('function foo(){console.log("foo");alert("foo");debugger;}').toString();
API
stripDebug(input)
Returns the modified Esprima AST which can be used to make additional modifications.
Call .toString()
to get the stringified output.
To prevent any side-effects, console.*
/alert*
is replaced with void 0
instead of being stripped.
input
Type: String
, Object
Pass in a string of JavaScript code or a Esprima compatible AST.
CLI
You can also use it as a CLI app by installing it globally:
$ npm install --global strip-debug
Usage
$ strip-debug src/app.js > dist/app.js
or pipe something to it:
$ echo 'function foo(){console.log("bar")}' | strip-debug
License
MIT © Sindre Sorhus