escover 1.10.0 → 1.11.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 +7 -0
- package/bin/escover.js +4 -2
- package/lib/cli/cli.js +2 -2
- package/lib/coverage-file/coverage-file.js +2 -2
- package/lib/coverage-file/lcov.js +17 -0
- package/lib/exit.js +2 -2
- package/lib/instrument/plugin-mark/continue.js +10 -0
- package/lib/instrument/plugin-mark/index.js +18 -2
- package/package.json +3 -1
package/ChangeLog
CHANGED
package/bin/escover.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import {cli} from '../lib/cli/cli.js';
|
|
4
|
-
import {
|
|
4
|
+
import {readCoverage} from '../lib/coverage-file/coverage-file.js';
|
|
5
|
+
import {readConfig} from '../lib/config.js';
|
|
5
6
|
|
|
6
7
|
cli({
|
|
7
8
|
argv: process.argv,
|
|
8
9
|
exit: process.exit,
|
|
9
|
-
|
|
10
|
+
readCoverage,
|
|
11
|
+
readConfig,
|
|
10
12
|
});
|
|
11
13
|
|
package/lib/cli/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import reportFiles from '../formatters/files.js';
|
|
|
8
8
|
|
|
9
9
|
const {ESCOVER_FORMAT, NODE_OPTIONS = ''} = process.env;
|
|
10
10
|
|
|
11
|
-
export const cli = ({argv, exit,
|
|
11
|
+
export const cli = ({argv, exit, readCoverage}) => {
|
|
12
12
|
const args = yargsParser(argv.slice(2), {
|
|
13
13
|
string: [
|
|
14
14
|
'format',
|
|
@@ -36,7 +36,7 @@ export const cli = ({argv, exit, read}) => {
|
|
|
36
36
|
execute('"' + cmd.join(`" "`) + '"', exit);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const coverage =
|
|
39
|
+
const coverage = readCoverage();
|
|
40
40
|
|
|
41
41
|
let output = '';
|
|
42
42
|
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
const NAME = 'escover';
|
|
17
17
|
const buildName = (a) => `${a}/${NAME}.json`;
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const writeCoverage = () => {
|
|
20
20
|
const files = getFileEntries();
|
|
21
21
|
|
|
22
22
|
if (!files.size)
|
|
@@ -33,7 +33,7 @@ export const write = () => {
|
|
|
33
33
|
writeFileSync(buildName(name), stringify(merged, null, 4));
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export const
|
|
36
|
+
export const readCoverage = () => {
|
|
37
37
|
const name = findCacheDir({
|
|
38
38
|
name: NAME,
|
|
39
39
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const {entries} = Object;
|
|
2
|
+
|
|
3
|
+
export const createLcov = (files) => {
|
|
4
|
+
const result = [];
|
|
5
|
+
|
|
6
|
+
for (const {name, lines} of files) {
|
|
7
|
+
result.push(`SF:${name}`);
|
|
8
|
+
for (const [line, covered] of entries(lines)) {
|
|
9
|
+
const count = covered ? 1 : 0;
|
|
10
|
+
result.push(`DA:${line},${count}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
result.push('end_of_record');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return result.join('\n');
|
|
17
|
+
};
|
package/lib/exit.js
CHANGED
|
@@ -3,9 +3,11 @@ import {
|
|
|
3
3
|
types,
|
|
4
4
|
operator,
|
|
5
5
|
} from 'putout';
|
|
6
|
+
|
|
6
7
|
import {addMarkToReturn} from './return.js';
|
|
7
8
|
import {addMarkToArrowFunction} from './arrow.js';
|
|
8
9
|
import {addMarkToThrow} from './throw.js';
|
|
10
|
+
import {addMarkToContinue} from './continue.js';
|
|
9
11
|
|
|
10
12
|
const {
|
|
11
13
|
NumericLiteral,
|
|
@@ -16,6 +18,7 @@ const {
|
|
|
16
18
|
const {
|
|
17
19
|
replaceWith,
|
|
18
20
|
compareAny,
|
|
21
|
+
compare,
|
|
19
22
|
} = operator;
|
|
20
23
|
|
|
21
24
|
const LINE = `__c4['🧨'](__l, __c)`;
|
|
@@ -93,13 +96,15 @@ export const fix = (path, {options}) => {
|
|
|
93
96
|
if (path.isReturnStatement())
|
|
94
97
|
return addMarkToReturn(path, lineNode);
|
|
95
98
|
|
|
96
|
-
if (path.isArrowFunctionExpression())
|
|
99
|
+
if (path.isArrowFunctionExpression())
|
|
97
100
|
return addMarkToArrowFunction(path, lineNode);
|
|
98
|
-
}
|
|
99
101
|
|
|
100
102
|
if (path.isThrowStatement())
|
|
101
103
|
return addMarkToThrow(path, lineNode);
|
|
102
104
|
|
|
105
|
+
if (path.isContinueStatement())
|
|
106
|
+
return addMarkToContinue(path, lineNode);
|
|
107
|
+
|
|
103
108
|
replaceWith(path, BlockStatement([
|
|
104
109
|
node,
|
|
105
110
|
]));
|
|
@@ -135,6 +140,17 @@ export const traverse = ({push}) => ({
|
|
|
135
140
|
|
|
136
141
|
push(path);
|
|
137
142
|
},
|
|
143
|
+
ContinueStatement(path) {
|
|
144
|
+
if (!path.parentPath.isBlockStatement())
|
|
145
|
+
return;
|
|
146
|
+
|
|
147
|
+
const {body} = path.parentPath.node;
|
|
148
|
+
|
|
149
|
+
if (compare(body[0], LINE))
|
|
150
|
+
return;
|
|
151
|
+
|
|
152
|
+
push(path);
|
|
153
|
+
},
|
|
138
154
|
LogicalExpression(path) {
|
|
139
155
|
if (compareAny(path.get('left'), EXCLUDE))
|
|
140
156
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"fix:lint": "madrun fix:lint",
|
|
28
28
|
"report": "madrun report",
|
|
29
29
|
"watcher": "madrun watcher",
|
|
30
|
+
"watch:test": "madrun watch:test",
|
|
30
31
|
"watch:lint": "madrun watch:lint",
|
|
31
32
|
"watch:tape": "madrun watch:tape",
|
|
32
33
|
"prewisdom": "madrun prewisdom"
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
"once": "^1.4.0",
|
|
41
42
|
"picomatch": "^2.3.1",
|
|
42
43
|
"putout": "^24.0.2",
|
|
44
|
+
"strip-ansi": "^7.0.1",
|
|
43
45
|
"table": "^6.8.0",
|
|
44
46
|
"try-catch": "^3.0.0",
|
|
45
47
|
"yargs-parser": "^21.0.0",
|