udebug

1.1.0 • Public • Published

udebug

travis-ci npm-version

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 = require('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 = require('udebug')
 
var code = [
  'var debug = require("debug"),',
  '    d     = debug("MYAPP")   ',
  '                             ',
  'function greet() {           ',
  '  d("#greet called")         ',
  '  return "hi"                ',
  '}                            '
].join('\n')
 
process.stdout.write(udebug(code, {filepath: 'a.js', debug: true}))

will output:

function greet() {
    return 'hi';
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImEuanMiXSwibmFtZXMiOlsiZ3JlZXQiXSwibWFwcGluZ3MiOiJBQUdBLFNBQVNBLEtBQVQsR0FBaUI7QUFBQSxJQUVmLE9BQU8sSUFBUCxDQUZlO0FBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZGVidWcgPSByZXF1aXJlKFwiZGVidWdcIiksXG4gICAgZCAgICAgPSBkZWJ1ZyhcIk1ZQVBQXCIpICAgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuZnVuY3Rpb24gZ3JlZXQoKSB7ICAgICAgICAgICBcbiAgZChcIiNncmVldCBjYWxsZWRcIikgICAgICAgICBcbiAgcmV0dXJuIFwiaGlcIiAgICAgICAgICAgICAgICBcbn0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIl19

Test

% npm install
% npm test

License

MIT (c) keik

Readme

Keywords

Package Sidebar

Install

npm i udebug

Weekly Downloads

2

Version

1.1.0

License

MIT

Last publish

Collaborators

  • keik