-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmerge-coverage.ts
More file actions
37 lines (32 loc) · 919 Bytes
/
merge-coverage.ts
File metadata and controls
37 lines (32 loc) · 919 Bytes
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
import * as fs from 'fs-extra';
import { createReporter } from 'istanbul-api';
import { createCoverageMap } from 'istanbul-lib-coverage';
import * as yargs from 'yargs';
async function main() {
const argv = yargs.options({
report: {
type: 'array', // array of string
desc: 'Path of json coverage report file',
demandOption: true
},
reporters: {
type: 'array',
default: ['json', 'lcov', 'text']
}
}).argv;
const reportFiles = argv.report as string[];
const reporters = argv.reporters as string[];
const map = createCoverageMap({});
reportFiles.forEach((file) => {
const r = fs.readJsonSync(file);
map.merge(r);
});
const reporter = createReporter();
await reporter.addAll(reporters);
reporter.write(map);
console.log('Created a merged coverage report in ./coverage');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});