escover 1.4.1 → 1.5.0
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/cli/cli.js +13 -3
- package/lib/formatters/files.js +76 -0
- package/lib/{report.js → formatters/lines.js} +1 -1
- package/package.json +2 -1
package/ChangeLog
CHANGED
package/lib/cli/cli.js
CHANGED
|
@@ -3,17 +3,24 @@ import tryCatch from 'try-catch';
|
|
|
3
3
|
import yargsParser from 'yargs-parser';
|
|
4
4
|
|
|
5
5
|
import {version} from './version.js';
|
|
6
|
-
import
|
|
6
|
+
import reportLines from '../formatters/lines.js';
|
|
7
|
+
import reportFiles from '../formatters/files.js';
|
|
7
8
|
|
|
8
9
|
export const cli = ({argv, exit, read}) => {
|
|
9
10
|
const args = yargsParser(argv.slice(2), {
|
|
11
|
+
string: [
|
|
12
|
+
'format',
|
|
13
|
+
],
|
|
10
14
|
boolean: [
|
|
11
15
|
'version',
|
|
12
16
|
],
|
|
13
17
|
alias: {
|
|
14
18
|
v: 'version',
|
|
19
|
+
f: 'format',
|
|
20
|
+
},
|
|
21
|
+
default: {
|
|
22
|
+
format: 'files',
|
|
15
23
|
},
|
|
16
|
-
configuration: {},
|
|
17
24
|
});
|
|
18
25
|
|
|
19
26
|
if (args.version) {
|
|
@@ -29,7 +36,10 @@ export const cli = ({argv, exit, read}) => {
|
|
|
29
36
|
|
|
30
37
|
const coverage = read();
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
if (args.format === 'lines')
|
|
40
|
+
return reportLines(coverage);
|
|
41
|
+
|
|
42
|
+
reportFiles(coverage);
|
|
33
43
|
};
|
|
34
44
|
|
|
35
45
|
function execute(cmd, exit) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
table,
|
|
3
|
+
getBorderCharacters,
|
|
4
|
+
} from 'table';
|
|
5
|
+
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
|
|
8
|
+
const CWD = process.cwd();
|
|
9
|
+
const {entries} = Object;
|
|
10
|
+
|
|
11
|
+
export default (coverageFile) => {
|
|
12
|
+
const files = parseCoverageFile(coverageFile);
|
|
13
|
+
const tableData = [
|
|
14
|
+
['File', 'Uncovered Lines'],
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
for (const {filename, covered, lines} of files) {
|
|
18
|
+
const uncoveredLines = lines.join(', ');
|
|
19
|
+
|
|
20
|
+
if (covered) {
|
|
21
|
+
tableData.push([chalk.green(filename), '']);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
tableData.push([chalk.red(filename), chalk.red(uncoveredLines)]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(table(tableData, {
|
|
29
|
+
drawHorizontalLine: (raw) => {
|
|
30
|
+
return !raw || raw === 1 || raw === files.length + 1;
|
|
31
|
+
},
|
|
32
|
+
columns: [{
|
|
33
|
+
paddingLeft: 0,
|
|
34
|
+
}],
|
|
35
|
+
border: {
|
|
36
|
+
...getBorderCharacters('void'),
|
|
37
|
+
topBody: '-',
|
|
38
|
+
bottomBody: '-',
|
|
39
|
+
joinBody: '-',
|
|
40
|
+
topJoin: '|',
|
|
41
|
+
bottomJoin: '|',
|
|
42
|
+
joinJoin: '|',
|
|
43
|
+
bodyJoin: '|',
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function parseUncoveredLines(lines) {
|
|
49
|
+
const uncoveredLines = [];
|
|
50
|
+
|
|
51
|
+
for (const [line, covered] of entries(lines)) {
|
|
52
|
+
if (covered)
|
|
53
|
+
continue;
|
|
54
|
+
|
|
55
|
+
uncoveredLines.push(line);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return uncoveredLines;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parseCoverageFile(coverageFile) {
|
|
62
|
+
const files = [];
|
|
63
|
+
for (const {name, lines} of coverageFile) {
|
|
64
|
+
const filename = name.replace(CWD + '/', '');
|
|
65
|
+
const uncoveredLines = parseUncoveredLines(lines);
|
|
66
|
+
|
|
67
|
+
files.push({
|
|
68
|
+
filename,
|
|
69
|
+
covered: !uncoveredLines.length,
|
|
70
|
+
lines: parseUncoveredLines(lines),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return files;
|
|
75
|
+
}
|
|
76
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "Coverage for EcmaScript Modules",
|
|
6
6
|
"main": "lib/escover.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"montag": "^1.2.1",
|
|
44
44
|
"once": "^1.4.0",
|
|
45
45
|
"putout": "^24.0.2",
|
|
46
|
+
"table": "^6.8.0",
|
|
46
47
|
"try-catch": "^3.0.0",
|
|
47
48
|
"yargs-parser": "^21.0.0",
|
|
48
49
|
"zenload": "^1.4.0"
|