escover 6.1.1 → 6.1.2
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 +5 -0
- package/lib/cli/cli.js +0 -1
- package/lib/config.js +4 -1
- package/lib/coverage-file/coverage-directory.js +0 -1
- package/lib/coverage-file/coverage-file.js +3 -5
- package/lib/escover.js +1 -1
- package/lib/instrument/index.js +13 -1
- package/lib/register.js +0 -1
- package/package.json +2 -1
- package/lib/fresh.js +0 -27
package/ChangeLog
CHANGED
package/lib/cli/cli.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -30,7 +30,10 @@ const defaults = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const readConfig = (overrides = {}) => {
|
|
33
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
find = findUpSync,
|
|
35
|
+
read = readFileSync,
|
|
36
|
+
} = overrides;
|
|
34
37
|
const name = find('.nycrc.json');
|
|
35
38
|
|
|
36
39
|
if (!name)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {writeFileSync, readFileSync} from 'node:fs';
|
|
2
2
|
import {join} from 'node:path';
|
|
3
3
|
import {tryCatch} from 'try-catch';
|
|
4
|
-
import {operator} from 'putout';
|
|
5
4
|
import {getFileEntries} from '../c4.js';
|
|
6
5
|
import {transform} from '../transform.js';
|
|
7
6
|
import {merge} from '../merge.js';
|
|
@@ -11,8 +10,6 @@ import {
|
|
|
11
10
|
} from './coverage-directory.js';
|
|
12
11
|
import {generateLcov, parseLcov} from './lcov.js';
|
|
13
12
|
|
|
14
|
-
const {getFile} = operator;
|
|
15
|
-
|
|
16
13
|
const LCOV = 'lcov.info';
|
|
17
14
|
|
|
18
15
|
export const writeCoverage = (overrides = {}) => {
|
|
@@ -36,7 +33,9 @@ export const writeCoverage = (overrides = {}) => {
|
|
|
36
33
|
};
|
|
37
34
|
|
|
38
35
|
export const readCoverage = (overrides = {}) => {
|
|
39
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
read = readFileSync,
|
|
38
|
+
} = overrides;
|
|
40
39
|
const dir = getCoverageDirectory();
|
|
41
40
|
const [error, data] = tryCatch(read, join(dir, LCOV), 'utf8');
|
|
42
41
|
|
|
@@ -45,4 +44,3 @@ export const readCoverage = (overrides = {}) => {
|
|
|
45
44
|
|
|
46
45
|
return parseLcov(data);
|
|
47
46
|
};
|
|
48
|
-
|
package/lib/escover.js
CHANGED
package/lib/instrument/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import putout from 'putout';
|
|
2
2
|
import * as convertOptionalToLogical from '@putout/plugin-convert-optional-to-logical';
|
|
3
|
+
import {tryCatch} from 'try-catch';
|
|
3
4
|
import * as mark from './plugin-mark/index.js';
|
|
4
5
|
|
|
6
|
+
const {assign} = Object;
|
|
7
|
+
|
|
5
8
|
export const instrument = (url, source) => {
|
|
6
9
|
const c4 = globalThis.__createC4(url);
|
|
7
10
|
|
|
8
|
-
const
|
|
11
|
+
const [error, result] = tryCatch(putout, source, {
|
|
9
12
|
printer: 'putout',
|
|
10
13
|
fixCount: 1,
|
|
11
14
|
rules: {
|
|
@@ -19,5 +22,14 @@ export const instrument = (url, source) => {
|
|
|
19
22
|
],
|
|
20
23
|
});
|
|
21
24
|
|
|
25
|
+
if (error) {
|
|
26
|
+
assign(error, {
|
|
27
|
+
message: `${url}: ${error.message}`,
|
|
28
|
+
});
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {code} = result;
|
|
33
|
+
|
|
22
34
|
return code;
|
|
23
35
|
};
|
package/lib/register.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2",
|
|
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",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"license": "MIT",
|
|
61
61
|
"devDependencies": {
|
|
62
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
62
63
|
"@putout/test": "^15.1.1",
|
|
63
64
|
"c8": "^11.0.0",
|
|
64
65
|
"escover": "file:.",
|
package/lib/fresh.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import {register} from 'node:module';
|
|
4
|
-
import {MessageChannel} from 'node:worker_threads';
|
|
5
|
-
|
|
6
|
-
// This example showcases how a message channel can be used to communicate
|
|
7
|
-
// between the main (application) thread and the hooks running on the hooks
|
|
8
|
-
// thread, by sending `port2` to the `initialize` hook.
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
|
|
11
|
-
// This example showcases how a message channel can be used to communicate
|
|
12
|
-
// between the main (application) thread and the hooks running on the hooks
|
|
13
|
-
// thread, by sending `port2` to the `initialize` hook.
|
|
14
|
-
const {port1, port2} = new MessageChannel();
|
|
15
|
-
|
|
16
|
-
port1.on('message', (msg) => {
|
|
17
|
-
assert.strictEqual(msg, 'increment: 2');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
register('./escover.js', {
|
|
21
|
-
parentURL: pathToFileURL(__filename),
|
|
22
|
-
data: {
|
|
23
|
-
number: 1,
|
|
24
|
-
port: port2,
|
|
25
|
-
},
|
|
26
|
-
transferList: [port2],
|
|
27
|
-
});
|