-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·46 lines (38 loc) · 980 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
46
#!/usr/bin/env node
var JSONStream = require('JSONStream');
var istanbul = require('istanbul');
var yargs = require('yargs');
var argv = yargs
.usage('Usage: $0 [options]')
.option('f', {
alias: 'format',
default: 'html',
describe: 'Report format'
})
.option('o', {
alias: 'output',
default: 'coverage',
describe: 'Output directory'
})
.help()
.argv;
var collector = new istanbul.Collector();
var reporter = new istanbul.Reporter(null, argv.o);
reporter.add(argv.f);
var stream = JSONStream.parse('*');
stream.on('data', function(data) {
collector.add(data);
console.log('Collected coverage data');
});
stream.on('end', function() {
reporter.write(collector, false, function(err) {
if (err) {
console.error('Failed to write coverage report');
console.error(err);
} else {
console.log('Finished writing coverage report');
}
});
});
process.stdin.pipe(stream);
console.log('Waiting for input...');