-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (29 loc) · 848 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var util = require('util'),
path = require('path'),
stream = require('stream'),
udebug = require('udebug')
module.exports = Undebuggify
util.inherits(Undebuggify, stream.Transform)
function Undebuggify(file, opts) {
var exts = ['.js', '.jsx', '.es', '.es6', '.coffee']
if (exts.indexOf(path.extname(file)) === -1)
return stream.PassThrough()
if (!(this instanceof Undebuggify))
return new Undebuggify(file, opts)
stream.Transform.call(this)
this._opts = opts
this._data = ''
this._filename = file
return this
}
Undebuggify.prototype._transform = function(buf, enc, callback) {
this._data += buf
callback()
}
Undebuggify.prototype._flush = function(callback) {
this.push(udebug(this._data, {
filepath: this._filename,
debug: this._opts._flags && this._opts._flags.debug
}))
callback()
}