escover 1.4.0 → 1.5.2
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 +24 -0
- package/bin/escover.js +1 -1
- package/lib/cli/cli.js +14 -4
- package/lib/{coverage.js → coverage-file.js} +0 -0
- package/lib/exit.js +1 -1
- package/lib/formatters/files.js +90 -0
- package/lib/{report.js → formatters/lines.js} +1 -1
- package/package.json +2 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
2022.01.17, v1.5.2
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- escover: add ability to override ZENLOAD && NODE_OPTIONS
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.17, v1.5.1
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- escover: add lines %
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
2022.01.17, v1.5.0
|
|
14
|
+
|
|
15
|
+
feature:
|
|
16
|
+
- escover: add formatter table
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
2022.01.15, v1.4.1
|
|
20
|
+
|
|
21
|
+
feature:
|
|
22
|
+
- escover: coverage -> coverage-file
|
|
23
|
+
|
|
24
|
+
|
|
1
25
|
2022.01.15, v1.4.0
|
|
2
26
|
|
|
3
27
|
feature:
|
package/bin/escover.js
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,16 +36,19 @@ 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) {
|
|
36
46
|
const [error] = tryCatch(execSync, cmd, {
|
|
37
47
|
stdio: [0, 1, 2],
|
|
38
48
|
env: {
|
|
39
|
-
...process.env,
|
|
40
49
|
NODE_OPTIONS: '--no-warnings --loader zenload',
|
|
41
50
|
ZENLOAD: 'escover,mock-import',
|
|
51
|
+
...process.env,
|
|
42
52
|
},
|
|
43
53
|
});
|
|
44
54
|
|
|
File without changes
|
package/lib/exit.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
table,
|
|
3
|
+
getBorderCharacters,
|
|
4
|
+
} from 'table';
|
|
5
|
+
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
|
|
8
|
+
const CWD = process.cwd();
|
|
9
|
+
const {
|
|
10
|
+
entries,
|
|
11
|
+
keys,
|
|
12
|
+
} = Object;
|
|
13
|
+
|
|
14
|
+
export default (coverageFile) => {
|
|
15
|
+
const files = parseCoverageFile(coverageFile);
|
|
16
|
+
|
|
17
|
+
const tableData = [
|
|
18
|
+
['File', '% Lines', 'Uncovered Lines #s'],
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
for (const {filename, covered, lines, percentLines} of files) {
|
|
22
|
+
const uncoveredLines = lines.join(', ');
|
|
23
|
+
|
|
24
|
+
if (covered) {
|
|
25
|
+
tableData.push([chalk.green(filename), chalk.green(percentLines), '']);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
tableData.push([chalk.red(filename), chalk.red(percentLines), chalk.red(uncoveredLines)]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
process.stdout.write(table(tableData, {
|
|
33
|
+
drawHorizontalLine: (raw) => {
|
|
34
|
+
return !raw || raw === 1 || raw === files.length + 1;
|
|
35
|
+
},
|
|
36
|
+
columns: [{
|
|
37
|
+
paddingLeft: 0,
|
|
38
|
+
}],
|
|
39
|
+
border: {
|
|
40
|
+
...getBorderCharacters('void'),
|
|
41
|
+
topBody: '-',
|
|
42
|
+
bottomBody: '-',
|
|
43
|
+
joinBody: '-',
|
|
44
|
+
topJoin: '|',
|
|
45
|
+
bottomJoin: '|',
|
|
46
|
+
joinJoin: '|',
|
|
47
|
+
bodyJoin: '|',
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function parseUncoveredLines(lines) {
|
|
53
|
+
const uncoveredLines = [];
|
|
54
|
+
|
|
55
|
+
for (const [line, covered] of entries(lines)) {
|
|
56
|
+
if (covered)
|
|
57
|
+
continue;
|
|
58
|
+
|
|
59
|
+
uncoveredLines.push(line);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return uncoveredLines;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parseCoverageFile(coverageFile) {
|
|
66
|
+
const files = [];
|
|
67
|
+
for (const {name, lines} of coverageFile) {
|
|
68
|
+
const filename = name.replace(CWD + '/', '');
|
|
69
|
+
const uncoveredLines = parseUncoveredLines(lines);
|
|
70
|
+
|
|
71
|
+
const linesCount = keys(lines).length;
|
|
72
|
+
const percentLines = getPercentLines(linesCount, uncoveredLines);
|
|
73
|
+
|
|
74
|
+
files.push({
|
|
75
|
+
filename,
|
|
76
|
+
covered: !uncoveredLines.length,
|
|
77
|
+
lines: uncoveredLines,
|
|
78
|
+
percentLines,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return files;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getPercentLines(linesCount, uncoveredLines) {
|
|
86
|
+
if (!linesCount)
|
|
87
|
+
return 100;
|
|
88
|
+
|
|
89
|
+
return 100 - Math.round(100 / linesCount * uncoveredLines.length);
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
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"
|