udebug
Remove visionmedia/debug related code using AST.
Install
npm install udebug
CLI
udebug src.js
will print results to stdout, or output to the file with -o
option:
udebug src.js -o dist.js
and you can pass -d
option to enable source map.
Stdin is also available:
echo 'var debug = require("debug")' | udebug
API
var udebug =
udebug(code, opts)
Remove visionmedia/debug related code from code
using AST.
-
code
:string
- target code
-
opts.filepath
:string
- filepath to attach source map
-
opts.debug
:boolean
- attach source map or not
Example
var udebug = var code = 'var debug = require("debug"),' ' d = debug("MYAPP") ' ' ' 'function greet() { ' ' d("#greet called") ' ' return "hi" ' '} ' processstdout
will output:
{ return 'hi';}//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImEuanMiXSwibmFtZXMiOlsiZ3JlZXQiXSwibWFwcGluZ3MiOiJBQUdBLFNBQVNBLEtBQVQsR0FBaUI7QUFBQSxJQUVmLE9BQU8sSUFBUCxDQUZlO0FBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZGVidWcgPSByZXF1aXJlKFwiZGVidWdcIiksXG4gICAgZCAgICAgPSBkZWJ1ZyhcIk1ZQVBQXCIpICAgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuZnVuY3Rpb24gZ3JlZXQoKSB7ICAgICAgICAgICBcbiAgZChcIiNncmVldCBjYWxsZWRcIikgICAgICAgICBcbiAgcmV0dXJuIFwiaGlcIiAgICAgICAgICAgICAgICBcbn0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIl19
Test
% npm install
% npm test
License
MIT (c) keik