escover 6.2.7 → 6.2.8
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
CHANGED
|
@@ -7,7 +7,14 @@ const makeRed = chalk.hex('#f44336');
|
|
|
7
7
|
|
|
8
8
|
export const getColor = (value) => value === 100 ? makeGreen : makeRed;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function truncateLeft(str, maxLength) {
|
|
11
|
+
if (str.length <= maxLength)
|
|
12
|
+
return str;
|
|
13
|
+
|
|
14
|
+
return `...${str.slice(str.length - maxLength + 5)}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function buildGroupedTable({files, showPercent, linesColWidth, fileColWidth}) {
|
|
11
18
|
const tableData = [];
|
|
12
19
|
|
|
13
20
|
if (showPercent)
|
|
@@ -35,7 +42,9 @@ export function buildGroupedTable(files, showPercent, linesColWidth) {
|
|
|
35
42
|
|
|
36
43
|
if (!hideFolders) {
|
|
37
44
|
const row = [];
|
|
38
|
-
|
|
45
|
+
|
|
46
|
+
const shortFolder = truncateLeft(folder, fileColWidth);
|
|
47
|
+
row.push(getColor(coverage)(shortFolder));
|
|
39
48
|
|
|
40
49
|
if (showPercent)
|
|
41
50
|
row.push(getColor(coverage)(`${coverage}%`));
|
|
@@ -44,15 +53,20 @@ export function buildGroupedTable(files, showPercent, linesColWidth) {
|
|
|
44
53
|
tableData.push(row);
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
for (const
|
|
56
|
+
for (const {covered, lines, fileName, percentLines} of group.files) {
|
|
48
57
|
const row = [];
|
|
49
|
-
|
|
58
|
+
const shortName = truncateLeft(fileName, fileColWidth);
|
|
59
|
+
const coloredShortName = covered ? makeGreen(shortName) : makeRed(shortName);
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
row.push(coloredShortName);
|
|
62
|
+
|
|
63
|
+
if (showPercent) {
|
|
64
|
+
const percent = percentLines === 100 ? makeGreen(`${percentLines}%`) : makeRed(`${percentLines}%`);
|
|
65
|
+
row.push(percent);
|
|
66
|
+
}
|
|
53
67
|
|
|
54
|
-
row.push(
|
|
55
|
-
|
|
68
|
+
row.push(covered ? '' : makeRed(formatLines(
|
|
69
|
+
lines,
|
|
56
70
|
linesColWidth,
|
|
57
71
|
)));
|
|
58
72
|
|
|
@@ -16,10 +16,14 @@ export function formatLines(nums, maxLen = 20) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function getShortenedRange(ranges, maxLen) {
|
|
19
|
-
const last = ranges
|
|
19
|
+
const last = ranges
|
|
20
|
+
.at(-1)
|
|
21
|
+
.toString();
|
|
20
22
|
|
|
21
23
|
for (let i = 1; i < ranges.length - 1; i++) {
|
|
22
|
-
const joined = `${ranges
|
|
24
|
+
const joined = `${ranges
|
|
25
|
+
.slice(0, -i)
|
|
26
|
+
.join(', ')} ... ${last}`;
|
|
23
27
|
|
|
24
28
|
if (joined.length <= maxLen)
|
|
25
29
|
return joined;
|
|
@@ -21,7 +21,12 @@ export default (coverageFile, {skipFull = false} = {}) => {
|
|
|
21
21
|
const percentColWidth = showPercent ? 7 : 0;
|
|
22
22
|
|
|
23
23
|
const fileColWidth = Math.max(10, totalWidth - linesColWidth - percentColWidth - 6 - 4);
|
|
24
|
-
const tableData = buildGroupedTable(
|
|
24
|
+
const tableData = buildGroupedTable({
|
|
25
|
+
files,
|
|
26
|
+
showPercent,
|
|
27
|
+
linesColWidth,
|
|
28
|
+
fileColWidth,
|
|
29
|
+
});
|
|
25
30
|
|
|
26
31
|
const options = createTableOptions({
|
|
27
32
|
showPercent,
|