escover 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +6 -0
- package/lib/formatters/files.js +21 -7
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/lib/formatters/files.js
CHANGED
|
@@ -6,26 +6,30 @@ import {
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
|
|
8
8
|
const CWD = process.cwd();
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
entries,
|
|
11
|
+
keys,
|
|
12
|
+
} = Object;
|
|
10
13
|
|
|
11
14
|
export default (coverageFile) => {
|
|
12
15
|
const files = parseCoverageFile(coverageFile);
|
|
16
|
+
|
|
13
17
|
const tableData = [
|
|
14
|
-
['File', 'Uncovered Lines'],
|
|
18
|
+
['File', '% Lines', 'Uncovered Lines #s'],
|
|
15
19
|
];
|
|
16
20
|
|
|
17
|
-
for (const {filename, covered, lines} of files) {
|
|
21
|
+
for (const {filename, covered, lines, percentLines} of files) {
|
|
18
22
|
const uncoveredLines = lines.join(', ');
|
|
19
23
|
|
|
20
24
|
if (covered) {
|
|
21
|
-
tableData.push([chalk.green(filename), '']);
|
|
25
|
+
tableData.push([chalk.green(filename), chalk.green(percentLines), '']);
|
|
22
26
|
continue;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
tableData.push([chalk.red(filename), chalk.red(uncoveredLines)]);
|
|
29
|
+
tableData.push([chalk.red(filename), chalk.red(percentLines), chalk.red(uncoveredLines)]);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
process.stdout.write(table(tableData, {
|
|
29
33
|
drawHorizontalLine: (raw) => {
|
|
30
34
|
return !raw || raw === 1 || raw === files.length + 1;
|
|
31
35
|
},
|
|
@@ -64,13 +68,23 @@ function parseCoverageFile(coverageFile) {
|
|
|
64
68
|
const filename = name.replace(CWD + '/', '');
|
|
65
69
|
const uncoveredLines = parseUncoveredLines(lines);
|
|
66
70
|
|
|
71
|
+
const linesCount = keys(lines).length;
|
|
72
|
+
const percentLines = getPercentLines(linesCount, uncoveredLines);
|
|
73
|
+
|
|
67
74
|
files.push({
|
|
68
75
|
filename,
|
|
69
76
|
covered: !uncoveredLines.length,
|
|
70
|
-
lines:
|
|
77
|
+
lines: uncoveredLines,
|
|
78
|
+
percentLines,
|
|
71
79
|
});
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
return files;
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
function getPercentLines(linesCount, uncoveredLines) {
|
|
86
|
+
if (!linesCount)
|
|
87
|
+
return 100;
|
|
88
|
+
|
|
89
|
+
return 100 - Math.round(100 / linesCount * uncoveredLines.length);
|
|
90
|
+
}
|