tr_flags.js
1.25 KB
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
38
39
40
41
42
43
44
var through = require('through2');
var mdeps = require('../');
var test = require('tap').test;
test('--debug passed to transforms', function (t) {
var empty = require.resolve('./tr_flags/empty.js');
t.plan(5);
var p
[true, false].forEach(function(debug) {
p = mdeps({
debug: debug,
transform: function (file, opts) {
t.equal(opts._flags.debug, debug, 'debug: ' + debug);
return through();
}
})
p.on('error', function (err) { return t.fail(err.message) })
p.end(empty);
p = mdeps({ debug: debug })
p.write({
transform: function (file, opts) {
t.equal(opts._flags.debug, debug, 'debug: ' + debug);
return through();
},
options: {}
})
p.on('error', function (err) { return t.fail(err.message) })
p.end(empty);
});
p = mdeps({ debug: true })
p.write({
transform: function (file, opts) {
t.equal(opts._flags, Infinity, 'transform arguments are preserved');
return through();
},
options: { _flags: Infinity }
})
p.on('error', function (err) { return t.fail(err.message) })
p.end(empty);
});