执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 Copyright 2012-2015, Yahoo Inc.
 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
 */
'use strict';
 
function LcovOnlyReport(opts) {
    this.file = opts.file || 'lcov.info';
    this.contentWriter = null;
}
 
LcovOnlyReport.prototype.onStart = function(root, context) {
    this.contentWriter = context.writer.writeFile(this.file);
};
 
LcovOnlyReport.prototype.onDetail = function(node) {
    const fc = node.getFileCoverage();
    const writer = this.contentWriter;
    const functions = fc.f;
    const functionMap = fc.fnMap;
    const lines = fc.getLineCoverage();
    const branches = fc.b;
    const branchMap = fc.branchMap;
    const summary = node.getCoverageSummary();
 
    writer.println('TN:'); //no test name
    writer.println('SF:' + fc.path);
 
    Object.keys(functionMap).forEach(key => {
        const meta = functionMap[key];
        writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));
    });
    writer.println('FNF:' + summary.functions.total);
    writer.println('FNH:' + summary.functions.covered);
 
    Object.keys(functionMap).forEach(key => {
        const stats = functions[key];
        const meta = functionMap[key];
        writer.println('FNDA:' + [stats, meta.name].join(','));
    });
 
    Object.keys(lines).forEach(key => {
        const stat = lines[key];
        writer.println('DA:' + [key, stat].join(','));
    });
    writer.println('LF:' + summary.lines.total);
    writer.println('LH:' + summary.lines.covered);
 
    Object.keys(branches).forEach(key => {
        const branchArray = branches[key];
        const meta = branchMap[key];
        const line = meta.loc.start.line;
        let i = 0;
        branchArray.forEach(b => {
            writer.println('BRDA:' + [line, key, i, b].join(','));
            i += 1;
        });
    });
    writer.println('BRF:' + summary.branches.total);
    writer.println('BRH:' + summary.branches.covered);
    writer.println('end_of_record');
};
 
LcovOnlyReport.prototype.onEnd = function() {
    this.contentWriter.close();
};
 
module.exports = LcovOnlyReport;