escover 1.3.2 → 1.4.1
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/{coverage.js → coverage-file.js} +1 -0
- package/lib/escover.js +7 -0
- package/lib/exit.js +1 -1
- package/lib/instrument/index.js +1 -1
- package/lib/instrument/plugin-mark/index.js +4 -9
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
2022.01.15, v1.4.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- escover: coverage -> coverage-file
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.15, v1.4.0
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- escover: add ability to preserve fileEntries
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
2022.01.15, v1.3.4
|
|
14
|
+
|
|
15
|
+
fix:
|
|
16
|
+
- escover: rm useless import
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
2022.01.15, v1.3.3
|
|
20
|
+
|
|
21
|
+
feature:
|
|
22
|
+
- escover: exclude not from current path
|
|
23
|
+
|
|
24
|
+
|
|
1
25
|
2022.01.15, v1.3.2
|
|
2
26
|
|
|
3
27
|
fix:
|
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/escover.js
CHANGED
|
@@ -9,6 +9,7 @@ import {createFileEntry} from './c4.js';
|
|
|
9
9
|
global.__createC4 = createFileEntry;
|
|
10
10
|
|
|
11
11
|
process.once('exit', exit);
|
|
12
|
+
const CWD = process.cwd();
|
|
12
13
|
|
|
13
14
|
const EXCLUDE = [
|
|
14
15
|
'.spec.',
|
|
@@ -26,6 +27,12 @@ export async function load(url, context, defaultLoad) {
|
|
|
26
27
|
format,
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
if (!url.includes(CWD))
|
|
31
|
+
return {
|
|
32
|
+
format,
|
|
33
|
+
source: rawSource,
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
if (exclude(url, EXCLUDE))
|
|
30
37
|
return {
|
|
31
38
|
format,
|
package/lib/exit.js
CHANGED
package/lib/instrument/index.js
CHANGED
|
@@ -35,15 +35,9 @@ function getLineNode(c4, {line, column}) {
|
|
|
35
35
|
export const report = () => 'Mark line';
|
|
36
36
|
|
|
37
37
|
export const fix = (path, {options}) => {
|
|
38
|
-
const {
|
|
39
|
-
parentPath,
|
|
40
|
-
node,
|
|
41
|
-
} = path;
|
|
38
|
+
const {node} = path;
|
|
42
39
|
|
|
43
|
-
const {start} = path.node.loc
|
|
44
|
-
|
|
45
|
-
if (!start)
|
|
46
|
-
return;
|
|
40
|
+
const {start} = path.node.loc;
|
|
47
41
|
|
|
48
42
|
const {
|
|
49
43
|
c4 = {
|
|
@@ -99,8 +93,9 @@ export const fix = (path, {options}) => {
|
|
|
99
93
|
if (path.isReturnStatement())
|
|
100
94
|
return addMarkToReturn(path, lineNode);
|
|
101
95
|
|
|
102
|
-
if (path.isArrowFunctionExpression())
|
|
96
|
+
if (path.isArrowFunctionExpression()) {
|
|
103
97
|
return addMarkToArrowFunction(path, lineNode);
|
|
98
|
+
}
|
|
104
99
|
|
|
105
100
|
if (path.isThrowStatement())
|
|
106
101
|
return addMarkToThrow(path, lineNode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@putout/test": "^4.1.0",
|
|
56
56
|
"c8": "^7.8.0",
|
|
57
|
-
"escover": ".",
|
|
57
|
+
"escover": "^1.0.0",
|
|
58
58
|
"eslint": "^8.3.0",
|
|
59
59
|
"eslint-plugin-node": "^11.1.0",
|
|
60
60
|
"eslint-plugin-putout": "^13.0.1",
|