|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2012-2015, Yahoo Inc.
|
|---|
| 3 | Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|---|
| 4 | */
|
|---|
| 5 | 'use strict';
|
|---|
| 6 | const { ReportBase } = require('istanbul-lib-report');
|
|---|
| 7 |
|
|---|
| 8 | class JsonReport extends ReportBase {
|
|---|
| 9 | constructor(opts) {
|
|---|
| 10 | super();
|
|---|
| 11 |
|
|---|
| 12 | this.file = opts.file || 'coverage-final.json';
|
|---|
| 13 | this.first = true;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | onStart(root, context) {
|
|---|
| 17 | this.contentWriter = context.writer.writeFile(this.file);
|
|---|
| 18 | this.contentWriter.write('{');
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | onDetail(node) {
|
|---|
| 22 | const fc = node.getFileCoverage();
|
|---|
| 23 | const key = fc.path;
|
|---|
| 24 | const cw = this.contentWriter;
|
|---|
| 25 |
|
|---|
| 26 | if (this.first) {
|
|---|
| 27 | this.first = false;
|
|---|
| 28 | } else {
|
|---|
| 29 | cw.write(',');
|
|---|
| 30 | }
|
|---|
| 31 | cw.write(JSON.stringify(key));
|
|---|
| 32 | cw.write(': ');
|
|---|
| 33 | cw.write(JSON.stringify(fc));
|
|---|
| 34 | cw.println('');
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | onEnd() {
|
|---|
| 38 | const cw = this.contentWriter;
|
|---|
| 39 | cw.println('}');
|
|---|
| 40 | cw.close();
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | module.exports = JsonReport;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.