-
Notifications
You must be signed in to change notification settings - Fork 42
/
index.js
45 lines (34 loc) · 945 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
38
39
40
41
42
43
44
45
var ISTANBUL = require('istanbul'),
Report = ISTANBUL.Report,
Collector = ISTANBUL.Collector;
/**
* Expose `Istanbul`.
*/
exports = module.exports = Istanbul;
/**
* Initialize a new Istanbul reporter.
*
* @param {Runner} runner
* @public
*/
function Istanbul(runner) {
runner.on('end', function(){
var reporters;
if (process.env.ISTANBUL_REPORTERS) {
reporters = process.env.ISTANBUL_REPORTERS.split(',');
} else {
reporters = ['text-summary', 'html'];
}
var reportDir = process.env.ISTANBUL_REPORT_DIR;
var opts = {};
if (reportDir) {
opts.dir = reportDir;
}
var cov = global.__coverage__ || {},
collector = new Collector();
collector.add(cov);
reporters.forEach(function(reporter) {
Report.create(reporter, opts).writeReport(collector, true);
});
});
}