escover 2.5.2 → 2.5.3
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 +7 -0
- package/bin/escover.js +0 -2
- package/lib/c4.js +0 -1
- package/lib/cli/cli.js +4 -2
- package/lib/cli/version.js +1 -0
- package/lib/config.js +1 -0
- package/lib/coverage-file/lcov.js +2 -0
- package/lib/escover.js +5 -2
- package/lib/exclude.js +1 -0
- package/lib/exit.js +1 -0
- package/lib/formatters/files.js +15 -4
- package/lib/formatters/lines.js +2 -0
- package/lib/instrument/index.js +1 -0
- package/lib/instrument/plugin-mark/argument.js +2 -0
- package/lib/instrument/plugin-mark/index.js +4 -4
- package/lib/transform.js +6 -2
- package/package.json +4 -5
package/ChangeLog
CHANGED
package/bin/escover.js
CHANGED
package/lib/c4.js
CHANGED
package/lib/cli/cli.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {execSync} from 'child_process';
|
|
2
2
|
import tryCatch from 'try-catch';
|
|
3
3
|
import yargsParser from 'yargs-parser';
|
|
4
|
-
|
|
5
4
|
import {version} from './version.js';
|
|
6
5
|
import reportLines from '../formatters/lines.js';
|
|
7
6
|
import reportFiles from '../formatters/files.js';
|
|
8
7
|
|
|
9
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
ESCOVER_FORMAT,
|
|
10
|
+
NODE_OPTIONS = '',
|
|
11
|
+
} = process.env;
|
|
10
12
|
|
|
11
13
|
export const cli = ({argv, exit, readCoverage}) => {
|
|
12
14
|
const args = yargsParser(argv.slice(2), {
|
package/lib/cli/version.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -5,6 +5,7 @@ export const generateLcov = (files) => {
|
|
|
5
5
|
|
|
6
6
|
for (const {name, lines} of files) {
|
|
7
7
|
result.push(`SF:${name}`);
|
|
8
|
+
|
|
8
9
|
for (const [line, covered] of entries(lines)) {
|
|
9
10
|
const count = covered ? 1 : 0;
|
|
10
11
|
result.push(`DA:${line},${count}`);
|
|
@@ -34,6 +35,7 @@ export const parseLcov = (lcov) => {
|
|
|
34
35
|
|
|
35
36
|
if (cmd === 'DA') {
|
|
36
37
|
const [line, covered] = arg.split(',');
|
|
38
|
+
|
|
37
39
|
lines[line] = Boolean(Number(covered));
|
|
38
40
|
continue;
|
|
39
41
|
}
|
package/lib/escover.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
-
|
|
3
2
|
import {instrument} from './instrument/index.js';
|
|
4
3
|
import {exit} from './exit.js';
|
|
5
4
|
import {createFileEntry} from './c4.js';
|
|
@@ -25,7 +24,10 @@ const EXCLUDE = [
|
|
|
25
24
|
];
|
|
26
25
|
|
|
27
26
|
export async function load(url, context, defaultLoad) {
|
|
28
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
format,
|
|
29
|
+
source: rawSource,
|
|
30
|
+
} = await defaultLoad(url, context, defaultLoad);
|
|
29
31
|
|
|
30
32
|
if (/commonjs|builtin/.test(format))
|
|
31
33
|
return {
|
|
@@ -60,3 +62,4 @@ export async function load(url, context, defaultLoad) {
|
|
|
60
62
|
source,
|
|
61
63
|
};
|
|
62
64
|
}
|
|
65
|
+
|
package/lib/exclude.js
CHANGED
package/lib/exit.js
CHANGED
package/lib/formatters/files.js
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
table,
|
|
3
3
|
getBorderCharacters,
|
|
4
4
|
} from 'table';
|
|
5
|
-
|
|
6
5
|
import chalk from 'chalk';
|
|
7
6
|
|
|
8
7
|
const CWD = process.cwd();
|
|
8
|
+
|
|
9
9
|
const {
|
|
10
10
|
entries,
|
|
11
11
|
keys,
|
|
@@ -22,11 +22,19 @@ export default (coverageFile) => {
|
|
|
22
22
|
const uncoveredLines = formatLines(lines);
|
|
23
23
|
|
|
24
24
|
if (covered) {
|
|
25
|
-
tableData.push([
|
|
25
|
+
tableData.push([
|
|
26
|
+
chalk.green(filename),
|
|
27
|
+
chalk.green(percentLines),
|
|
28
|
+
'',
|
|
29
|
+
]);
|
|
26
30
|
continue;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
tableData.push([
|
|
33
|
+
tableData.push([
|
|
34
|
+
chalk.red(filename),
|
|
35
|
+
chalk.red(percentLines),
|
|
36
|
+
chalk.red(uncoveredLines),
|
|
37
|
+
]);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
return table(tableData, {
|
|
@@ -52,7 +60,9 @@ export default (coverageFile) => {
|
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
export function formatLines(array) {
|
|
55
|
-
const lines = array
|
|
63
|
+
const lines = array
|
|
64
|
+
.slice(0, 10)
|
|
65
|
+
.join(', ');
|
|
56
66
|
|
|
57
67
|
if (array.length <= 10)
|
|
58
68
|
return lines;
|
|
@@ -103,3 +113,4 @@ export function getLinesPercent(linesCount, uncoveredLinesCount) {
|
|
|
103
113
|
|
|
104
114
|
return 100 - Math.round(100 / linesCount * uncoveredLinesCount);
|
|
105
115
|
}
|
|
116
|
+
|
package/lib/formatters/lines.js
CHANGED
|
@@ -7,6 +7,7 @@ export default (coverageFile) => {
|
|
|
7
7
|
const output = [];
|
|
8
8
|
const out = createOut(output);
|
|
9
9
|
const files = [];
|
|
10
|
+
|
|
10
11
|
const coverage = {
|
|
11
12
|
files,
|
|
12
13
|
coveredCount: 0,
|
|
@@ -47,6 +48,7 @@ export default (coverageFile) => {
|
|
|
47
48
|
out('🧨 should be covered');
|
|
48
49
|
out('---');
|
|
49
50
|
out(`lines:`);
|
|
51
|
+
|
|
50
52
|
for (const line of uncoveredLines) {
|
|
51
53
|
out(`️- ${chalk.red(line)} at file://${name}:${line}`);
|
|
52
54
|
}
|
package/lib/instrument/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
types,
|
|
4
4
|
operator,
|
|
5
5
|
} from 'putout';
|
|
6
|
-
|
|
7
6
|
import {addMarkToArgument} from './argument.js';
|
|
8
7
|
import {addMarkToArrowFunction} from './arrow.js';
|
|
9
8
|
|
|
@@ -23,6 +22,7 @@ const {
|
|
|
23
22
|
} = operator;
|
|
24
23
|
|
|
25
24
|
const LINE = `__c4['🧨'](__l, __c)`;
|
|
25
|
+
|
|
26
26
|
const buildLineNode = template(LINE, {
|
|
27
27
|
placeholderPattern: /^__[a-z]$/,
|
|
28
28
|
});
|
|
@@ -104,9 +104,7 @@ export const fix = (path, {options}) => {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
replaceWith(path, BlockStatement([
|
|
108
|
-
node,
|
|
109
|
-
]));
|
|
107
|
+
replaceWith(path, BlockStatement([node]));
|
|
110
108
|
};
|
|
111
109
|
|
|
112
110
|
const EXCLUDE = [
|
|
@@ -117,11 +115,13 @@ const EXCLUDE = [
|
|
|
117
115
|
];
|
|
118
116
|
|
|
119
117
|
const SEQUENCE = `(${LINE}, __z)`;
|
|
118
|
+
|
|
120
119
|
const isExclude = (node) => {
|
|
121
120
|
const templates = [
|
|
122
121
|
...EXCLUDE,
|
|
123
122
|
SEQUENCE,
|
|
124
123
|
];
|
|
124
|
+
|
|
125
125
|
return compareAny(node, templates, {
|
|
126
126
|
findUp: false,
|
|
127
127
|
});
|
package/lib/transform.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
const sort = (a) =>
|
|
1
|
+
const sort = (a) => {
|
|
2
|
+
const sorted = Array
|
|
3
|
+
.from(a.entries())
|
|
4
|
+
.sort();
|
|
5
|
+
return new Map(sorted);
|
|
6
|
+
};
|
|
2
7
|
|
|
3
8
|
const isBool = (a) => typeof a === 'boolean';
|
|
4
9
|
|
|
@@ -34,4 +39,3 @@ function mergeLines(places) {
|
|
|
34
39
|
|
|
35
40
|
return result;
|
|
36
41
|
}
|
|
37
|
-
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
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",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"commitType": "colon",
|
|
9
8
|
"bin": {
|
|
10
9
|
"escover": "bin/escover.js"
|
|
11
10
|
},
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
42
|
"chalk": "^5.0.0",
|
|
44
|
-
"find-cache-dir": "^
|
|
43
|
+
"find-cache-dir": "^4.0.0",
|
|
45
44
|
"find-up": "^6.2.0",
|
|
46
45
|
"mock-import": "^3.0.1",
|
|
47
46
|
"montag": "^1.2.1",
|
|
@@ -59,12 +58,12 @@
|
|
|
59
58
|
},
|
|
60
59
|
"license": "MIT",
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@putout/test": "^
|
|
61
|
+
"@putout/test": "^6.4.0",
|
|
63
62
|
"c8": "^7.8.0",
|
|
64
63
|
"escover": "^2.0.1",
|
|
65
64
|
"eslint": "^8.3.0",
|
|
66
65
|
"eslint-plugin-n": "^15.2.4",
|
|
67
|
-
"eslint-plugin-putout": "^
|
|
66
|
+
"eslint-plugin-putout": "^17.5.1",
|
|
68
67
|
"madrun": "^9.0.0",
|
|
69
68
|
"supertape": "^8.0.1"
|
|
70
69
|
}
|