escover 1.3.3 → 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 +24 -0
- package/bin/escover.js +1 -1
- package/lib/c4.js +27 -8
- package/lib/cli/cli.js +13 -3
- package/lib/{coverage.js → coverage-file.js} +1 -0
- package/lib/exit.js +1 -1
- package/lib/formatters/files.js +76 -0
- package/lib/{report.js → formatters/lines.js} +1 -1
- package/lib/instrument/index.js +1 -1
- package/package.json +2 -1
package/ChangeLog
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
2022.01.17, v1.5.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- escover: add formatter table
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.15, v1.4.1
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- escover: coverage -> coverage-file
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
2022.01.15, v1.4.0
|
|
14
|
+
|
|
15
|
+
feature:
|
|
16
|
+
- escover: add ability to preserve fileEntries
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
2022.01.15, v1.3.4
|
|
20
|
+
|
|
21
|
+
fix:
|
|
22
|
+
- escover: rm useless import
|
|
23
|
+
|
|
24
|
+
|
|
1
25
|
2022.01.15, v1.3.3
|
|
2
26
|
|
|
3
27
|
feature:
|
package/bin/escover.js
CHANGED
package/lib/c4.js
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
const noop = () => {};
|
|
2
2
|
|
|
3
|
+
global.__fileEntries = global.__fileEntries || new Map();
|
|
4
|
+
|
|
5
|
+
export const {__fileEntries} = global;
|
|
3
6
|
export const createFileEntry = (url) => {
|
|
4
|
-
|
|
7
|
+
url = url.replace(/\?.*$/, '');
|
|
8
|
+
let lines = __fileEntries.get(url);
|
|
9
|
+
|
|
10
|
+
if (lines) {
|
|
11
|
+
return {
|
|
12
|
+
'🧨': set(lines),
|
|
13
|
+
'init': noop,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
lines = new Map();
|
|
18
|
+
|
|
5
19
|
__fileEntries.set(url, lines);
|
|
6
20
|
|
|
7
21
|
return {
|
|
8
|
-
'🧨': (
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
'init': (line, column) => {
|
|
12
|
-
lines.set(`${line}:${column}`, false);
|
|
13
|
-
},
|
|
22
|
+
'🧨': set(lines),
|
|
23
|
+
'init': init(lines),
|
|
14
24
|
};
|
|
15
25
|
};
|
|
16
26
|
|
|
27
|
+
const set = (lines) => (line, column) => {
|
|
28
|
+
lines.set(`${line}:${column}`, true);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const init = (lines) => (line, column) => {
|
|
32
|
+
lines.set(`${line}:${column}`, false);
|
|
33
|
+
};
|
|
34
|
+
|
|
17
35
|
export const getFileEntries = () => __fileEntries;
|
|
36
|
+
|
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) {
|
package/lib/exit.js
CHANGED
|
@@ -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/lib/instrument/index.js
CHANGED
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"
|