escover 4.0.1 โ 4.2.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 +17 -0
- package/README.md +1 -1
- package/lib/c4.js +1 -2
- package/lib/cli/cli.js +2 -11
- package/lib/coverage-file/coverage-file.js +3 -9
- package/lib/coverage-file/find-cache-dir.js +0 -1
- package/lib/escover.js +1 -6
- package/lib/formatters/files.js +0 -1
- package/lib/fresh.js +2 -5
- package/lib/instrument/plugin-mark/index.js +5 -10
- package/lib/register.js +8 -7
- package/package.json +13 -14
package/ChangeLog
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
2024.06.07, v4.2.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- a14d18d escover: @putout/test v10.0.0
|
|
5
|
+
- 1b1e4e9 escover: eslint v9.4.0
|
|
6
|
+
- 21f9710 escover: picomatch v4.0.2
|
|
7
|
+
|
|
8
|
+
2024.01.29, v4.1.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- 51103b4 escover: find-up v7.0.0
|
|
12
|
+
- 427406f escover: c8 v9.1.0
|
|
13
|
+
- 0d53d2f escover: @putout/test v8.4.0
|
|
14
|
+
- e6fde48 escover: eslint-plugin-putout v22.3.1
|
|
15
|
+
- 4e58f46 escover: putout v35.0.1
|
|
16
|
+
- f57fb20 escover: supertape v10.0.0
|
|
17
|
+
|
|
1
18
|
2023.12.10, v4.0.1
|
|
2
19
|
|
|
3
20
|
feature:
|
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ You can choose formatter with `ESCOVER_FORMAT` env variable.
|
|
|
90
90
|
|
|
91
91
|
## What if I want to use ๐ฉ`ESCover` with `mock-import`?
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
[`mock-import`](https://github.com/coderaiser/mock-import) is used by default in ๐ฉ`ESCover`.
|
|
94
94
|
|
|
95
95
|
Install it with:
|
|
96
96
|
|
package/lib/c4.js
CHANGED
package/lib/cli/cli.js
CHANGED
|
@@ -32,9 +32,8 @@ export const cli = ({argv, exit, readCoverage}) => {
|
|
|
32
32
|
|
|
33
33
|
const cmd = argv.slice(2);
|
|
34
34
|
|
|
35
|
-
if (cmd.length)
|
|
35
|
+
if (cmd.length)
|
|
36
36
|
execute(`"${cmd.join('" "')}"`, noop);
|
|
37
|
-
}
|
|
38
37
|
|
|
39
38
|
const coverage = readCoverage();
|
|
40
39
|
|
|
@@ -50,25 +49,17 @@ export const cli = ({argv, exit, readCoverage}) => {
|
|
|
50
49
|
|
|
51
50
|
export const isSuccess = (error) => !error || error?.status === Number(process.env.ESCOVER_SUCCESS_EXIT_CODE);
|
|
52
51
|
|
|
53
|
-
export function createZenload() {
|
|
54
|
-
return {
|
|
55
|
-
ZENLOAD: 'escover,mock-import',
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
52
|
function execute(cmd, exit) {
|
|
60
53
|
const [error] = tryCatch(execSync, cmd, {
|
|
61
54
|
stdio: [0, 1, 2],
|
|
62
55
|
env: {
|
|
63
|
-
...createZenload,
|
|
64
56
|
...process.env,
|
|
65
57
|
NODE_OPTIONS: ESCOVER_NODE_OPTIONS,
|
|
66
58
|
},
|
|
67
59
|
});
|
|
68
60
|
|
|
69
|
-
if (isSuccess(error))
|
|
61
|
+
if (isSuccess(error))
|
|
70
62
|
return exit(0);
|
|
71
|
-
}
|
|
72
63
|
|
|
73
64
|
if (error) {
|
|
74
65
|
console.error(error.message);
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
writeFileSync,
|
|
3
|
-
readFileSync,
|
|
4
|
-
} from 'node:fs';
|
|
5
|
-
import tryCatch from 'try-catch';
|
|
1
|
+
import {writeFileSync, readFileSync} from 'node:fs';
|
|
6
2
|
import {join} from 'node:path';
|
|
3
|
+
import tryCatch from 'try-catch';
|
|
7
4
|
import {getFileEntries} from '../c4.js';
|
|
8
5
|
import {transform} from '../transform.js';
|
|
9
6
|
import {merge} from '../merge.js';
|
|
10
7
|
import {findCacheDir} from './find-cache-dir.js';
|
|
11
|
-
import {
|
|
12
|
-
generateLcov,
|
|
13
|
-
parseLcov,
|
|
14
|
-
} from './lcov.js';
|
|
8
|
+
import {generateLcov, parseLcov} from './lcov.js';
|
|
15
9
|
|
|
16
10
|
const LCOV = 'lcov.info';
|
|
17
11
|
|
package/lib/escover.js
CHANGED
|
@@ -2,15 +2,11 @@ import process from 'node:process';
|
|
|
2
2
|
import montag from 'montag';
|
|
3
3
|
import {instrument} from './instrument/index.js';
|
|
4
4
|
import {createFileEntry} from './c4.js';
|
|
5
|
-
import {
|
|
6
|
-
readConfig,
|
|
7
|
-
isExclude,
|
|
8
|
-
} from './config.js';
|
|
5
|
+
import {readConfig, isExclude} from './config.js';
|
|
9
6
|
import {writeCoverage} from './coverage-file/coverage-file.js';
|
|
10
7
|
|
|
11
8
|
global.__createC4 = createFileEntry;
|
|
12
9
|
|
|
13
|
-
const port = {};
|
|
14
10
|
const CWD = process.cwd();
|
|
15
11
|
const {exclude} = readConfig();
|
|
16
12
|
|
|
@@ -85,4 +81,3 @@ export async function load(url, context, defaultLoad) {
|
|
|
85
81
|
shortCircuit: true,
|
|
86
82
|
};
|
|
87
83
|
}
|
|
88
|
-
|
package/lib/formatters/files.js
CHANGED
package/lib/fresh.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fileURLToPath,
|
|
3
|
-
pathToFileURL,
|
|
4
|
-
} from 'node:url';
|
|
1
|
+
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
5
2
|
import assert from 'node:assert';
|
|
6
3
|
import {register} from 'node:module';
|
|
7
4
|
import {MessageChannel} from 'node:worker_threads';
|
|
@@ -10,6 +7,7 @@ import {MessageChannel} from 'node:worker_threads';
|
|
|
10
7
|
// between the main (application) thread and the hooks running on the hooks
|
|
11
8
|
// thread, by sending `port2` to the `initialize` hook.
|
|
12
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
|
|
13
11
|
// This example showcases how a message channel can be used to communicate
|
|
14
12
|
// between the main (application) thread and the hooks running on the hooks
|
|
15
13
|
// thread, by sending `port2` to the `initialize` hook.
|
|
@@ -27,4 +25,3 @@ register('./escover.js', {
|
|
|
27
25
|
},
|
|
28
26
|
transferList: [port2],
|
|
29
27
|
});
|
|
30
|
-
|
|
@@ -44,14 +44,13 @@ const findLoc = (path) => {
|
|
|
44
44
|
const current = path.find(isLoc);
|
|
45
45
|
const {loc} = current.node;
|
|
46
46
|
|
|
47
|
-
if (current.__escover_loc_column)
|
|
47
|
+
if (current.__escover_loc_column)
|
|
48
48
|
return {
|
|
49
49
|
start: {
|
|
50
50
|
...loc.start,
|
|
51
51
|
column: ++current.__escover_loc_column,
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
}
|
|
55
54
|
|
|
56
55
|
current.__escover_loc_column = 1;
|
|
57
56
|
|
|
@@ -103,12 +102,11 @@ export const fix = (path, {options}) => {
|
|
|
103
102
|
if (path.isReturnStatement() || path.isThrowStatement())
|
|
104
103
|
return addMarkToArgument(path, lineNode);
|
|
105
104
|
|
|
106
|
-
if (path.isContinueStatement() || path.isBreakStatement())
|
|
105
|
+
if (path.isContinueStatement() || path.isBreakStatement())
|
|
107
106
|
return replaceWithMultiple(path, [
|
|
108
107
|
lineNode,
|
|
109
108
|
path.node,
|
|
110
109
|
]);
|
|
111
|
-
}
|
|
112
110
|
|
|
113
111
|
if (path.isExpression()) {
|
|
114
112
|
const {node} = path;
|
|
@@ -193,9 +191,8 @@ export const traverse = ({push}) => ({
|
|
|
193
191
|
push(path);
|
|
194
192
|
},
|
|
195
193
|
SequenceExpression(path) {
|
|
196
|
-
if (compare(path, `(${LINE}, __z)`))
|
|
194
|
+
if (compare(path, `(${LINE}, __z)`))
|
|
197
195
|
return;
|
|
198
|
-
}
|
|
199
196
|
|
|
200
197
|
const expressions = path.get('expressions');
|
|
201
198
|
|
|
@@ -207,9 +204,8 @@ export const traverse = ({push}) => ({
|
|
|
207
204
|
}
|
|
208
205
|
},
|
|
209
206
|
UpdateExpression(path) {
|
|
210
|
-
if (compare(path, `(${LINE}, __z)`))
|
|
207
|
+
if (compare(path, `(${LINE}, __z)`))
|
|
211
208
|
return;
|
|
212
|
-
}
|
|
213
209
|
|
|
214
210
|
push(path);
|
|
215
211
|
},
|
|
@@ -226,8 +222,7 @@ export const traverse = ({push}) => ({
|
|
|
226
222
|
if (alternatePath.isIfStatement())
|
|
227
223
|
return;
|
|
228
224
|
|
|
229
|
-
if (!alternatePath.isBlockStatement() && !isExclude(alternatePath))
|
|
225
|
+
if (!alternatePath.isBlockStatement() && !isExclude(alternatePath))
|
|
230
226
|
push(alternatePath);
|
|
231
|
-
}
|
|
232
227
|
},
|
|
233
228
|
});
|
package/lib/register.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { MessageChannel } from 'node:worker_threads';
|
|
1
|
+
import {register} from 'node:module';
|
|
2
|
+
import {MessageChannel} from 'node:worker_threads';
|
|
4
3
|
|
|
5
|
-
const {
|
|
4
|
+
const {port1, port2} = new MessageChannel();
|
|
6
5
|
|
|
7
6
|
initialize({
|
|
8
|
-
port: port1
|
|
7
|
+
port: port1,
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
register('./escover.js', import.meta.url, {
|
|
12
|
-
|
|
13
|
-
data: {
|
|
11
|
+
parentURL: import.meta.url,
|
|
12
|
+
data: {
|
|
13
|
+
port: port2,
|
|
14
|
+
},
|
|
14
15
|
transferList: [port2],
|
|
15
16
|
});
|
|
16
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.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",
|
|
@@ -44,30 +44,29 @@
|
|
|
44
44
|
"@putout/plugin-convert-optional-to-logical": "^3.1.0",
|
|
45
45
|
"chalk": "^5.0.0",
|
|
46
46
|
"find-cache-dir": "^5.0.0",
|
|
47
|
-
"find-up": "^
|
|
47
|
+
"find-up": "^7.0.0",
|
|
48
48
|
"mock-import": "^4.0.0",
|
|
49
49
|
"montag": "^1.2.1",
|
|
50
50
|
"once": "^1.4.0",
|
|
51
|
-
"picomatch": "^
|
|
52
|
-
"putout": "^
|
|
51
|
+
"picomatch": "^4.0.2",
|
|
52
|
+
"putout": "^35.0.1",
|
|
53
53
|
"strip-ansi": "^7.0.1",
|
|
54
54
|
"table": "^6.8.0",
|
|
55
55
|
"try-catch": "^3.0.0",
|
|
56
|
-
"yargs-parser": "^21.0.0"
|
|
57
|
-
"zenload": "^2.0.0"
|
|
56
|
+
"yargs-parser": "^21.0.0"
|
|
58
57
|
},
|
|
59
58
|
"engines": {
|
|
60
|
-
"node": ">=18"
|
|
59
|
+
"node": ">=18.19"
|
|
61
60
|
},
|
|
62
61
|
"license": "MIT",
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@putout/
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"eslint
|
|
69
|
-
"eslint-plugin-putout": "^
|
|
63
|
+
"@putout/eslint-flat": "^2.0.0",
|
|
64
|
+
"@putout/test": "^10.0.0",
|
|
65
|
+
"c8": "^9.1.0",
|
|
66
|
+
"escover": "file:.",
|
|
67
|
+
"eslint": "^9.4.0",
|
|
68
|
+
"eslint-plugin-putout": "^22.3.1",
|
|
70
69
|
"madrun": "^10.0.0",
|
|
71
|
-
"supertape": "^
|
|
70
|
+
"supertape": "^10.0.0"
|
|
72
71
|
}
|
|
73
72
|
}
|