escover 2.5.2 → 3.0.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 +13 -0
- package/bin/escover.js +0 -2
- package/lib/c4.js +0 -1
- package/lib/cli/cli.js +5 -3
- 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 +5 -7
- package/lib/instrument/plugin-mark/argument.js +2 -0
- package/lib/instrument/plugin-mark/index.js +6 -5
- package/lib/transform.js +7 -2
- package/package.json +6 -5
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2023.05.03, v3.0.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 49fca58 escover: use @putout/printer
|
|
5
|
+
- 1dfbea6 escover: use @putout/printer
|
|
6
|
+
|
|
7
|
+
2023.05.02, v2.5.3
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- c3b81da package: find-cache-dir v4.0.0
|
|
11
|
+
- 0f5fa40 package: @putout/test v6.4.0
|
|
12
|
+
- 0625eff package: eslint-plugin-putout v17.5.1
|
|
13
|
+
|
|
1
14
|
2023.03.06, v2.5.2
|
|
2
15
|
|
|
3
16
|
feature:
|
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), {
|
|
@@ -33,7 +35,7 @@ export const cli = ({argv, exit, readCoverage}) => {
|
|
|
33
35
|
const cmd = argv.slice(2);
|
|
34
36
|
|
|
35
37
|
if (cmd.length) {
|
|
36
|
-
execute(
|
|
38
|
+
execute(`"${cmd.join('" "')}"`, exit);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
const coverage = readCoverage();
|
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
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
transform,
|
|
5
|
-
} from 'putout';
|
|
1
|
+
import {transform} from 'putout';
|
|
2
|
+
import {parse} from '@babel/parser';
|
|
3
|
+
import {print} from '@putout/printer';
|
|
6
4
|
import * as mark from './plugin-mark/index.js';
|
|
7
5
|
|
|
8
6
|
export const instrument = (url, source) => {
|
|
9
7
|
const c4 = global.__createC4(url);
|
|
8
|
+
|
|
10
9
|
const options = {
|
|
11
10
|
fixCount: 1,
|
|
12
11
|
rules: {
|
|
@@ -22,8 +21,7 @@ export const instrument = (url, source) => {
|
|
|
22
21
|
const ast = parse(source);
|
|
23
22
|
|
|
24
23
|
transform(ast, source, options);
|
|
25
|
-
const {code} = generate(ast);
|
|
26
24
|
|
|
27
|
-
return
|
|
25
|
+
return print(ast);
|
|
28
26
|
};
|
|
29
27
|
|
|
@@ -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,11 +22,13 @@ 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
|
});
|
|
29
29
|
|
|
30
30
|
function getLineNode(c4, {line, column}) {
|
|
31
|
+
debugger;
|
|
31
32
|
c4.init(line, column);
|
|
32
33
|
|
|
33
34
|
return buildLineNode({
|
|
@@ -40,7 +41,7 @@ export const report = () => 'Mark line';
|
|
|
40
41
|
|
|
41
42
|
export const fix = (path, {options}) => {
|
|
42
43
|
const {node} = path;
|
|
43
|
-
const {start} = path.node.loc
|
|
44
|
+
const {start} = path.node.loc;
|
|
44
45
|
|
|
45
46
|
const {
|
|
46
47
|
c4 = {
|
|
@@ -104,9 +105,7 @@ export const fix = (path, {options}) => {
|
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
replaceWith(path, BlockStatement([
|
|
108
|
-
node,
|
|
109
|
-
]));
|
|
108
|
+
replaceWith(path, BlockStatement([node]));
|
|
110
109
|
};
|
|
111
110
|
|
|
112
111
|
const EXCLUDE = [
|
|
@@ -117,11 +116,13 @@ const EXCLUDE = [
|
|
|
117
116
|
];
|
|
118
117
|
|
|
119
118
|
const SEQUENCE = `(${LINE}, __z)`;
|
|
119
|
+
|
|
120
120
|
const isExclude = (node) => {
|
|
121
121
|
const templates = [
|
|
122
122
|
...EXCLUDE,
|
|
123
123
|
SEQUENCE,
|
|
124
124
|
];
|
|
125
|
+
|
|
125
126
|
return compareAny(node, templates, {
|
|
126
127
|
findUp: false,
|
|
127
128
|
});
|
package/lib/transform.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
const sort = (a) =>
|
|
1
|
+
const sort = (a) => {
|
|
2
|
+
const sorted = Array
|
|
3
|
+
.from(a.entries())
|
|
4
|
+
.sort();
|
|
5
|
+
|
|
6
|
+
return new Map(sorted);
|
|
7
|
+
};
|
|
2
8
|
|
|
3
9
|
const isBool = (a) => typeof a === 'boolean';
|
|
4
10
|
|
|
@@ -34,4 +40,3 @@ function mergeLines(places) {
|
|
|
34
40
|
|
|
35
41
|
return result;
|
|
36
42
|
}
|
|
37
|
-
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"commitType": "colon",
|
|
9
8
|
"bin": {
|
|
10
9
|
"escover": "bin/escover.js"
|
|
11
10
|
},
|
|
@@ -40,8 +39,10 @@
|
|
|
40
39
|
"prewisdom": "madrun prewisdom"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
42
|
+
"@babel/parser": "^7.21.8",
|
|
43
|
+
"@putout/printer": "^1.80.3",
|
|
43
44
|
"chalk": "^5.0.0",
|
|
44
|
-
"find-cache-dir": "^
|
|
45
|
+
"find-cache-dir": "^4.0.0",
|
|
45
46
|
"find-up": "^6.2.0",
|
|
46
47
|
"mock-import": "^3.0.1",
|
|
47
48
|
"montag": "^1.2.1",
|
|
@@ -59,12 +60,12 @@
|
|
|
59
60
|
},
|
|
60
61
|
"license": "MIT",
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@putout/test": "^
|
|
63
|
+
"@putout/test": "^6.4.0",
|
|
63
64
|
"c8": "^7.8.0",
|
|
64
65
|
"escover": "^2.0.1",
|
|
65
66
|
"eslint": "^8.3.0",
|
|
66
67
|
"eslint-plugin-n": "^15.2.4",
|
|
67
|
-
"eslint-plugin-putout": "^
|
|
68
|
+
"eslint-plugin-putout": "^17.5.1",
|
|
68
69
|
"madrun": "^9.0.0",
|
|
69
70
|
"supertape": "^8.0.1"
|
|
70
71
|
}
|