escover 1.6.0 → 1.7.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 +6 -0
- package/README.md +4 -0
- package/lib/config.js +31 -0
- package/lib/escover.js +13 -7
- package/package.json +2 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
package/lib/config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {readFileSync} from 'fs';
|
|
2
|
+
import once from 'once';
|
|
3
|
+
import picomatch from 'picomatch';
|
|
4
|
+
import {findUpSync} from 'find-up';
|
|
5
|
+
|
|
6
|
+
const {parse} = JSON;
|
|
7
|
+
|
|
8
|
+
export const isExclude = (name, patterns) => {
|
|
9
|
+
const isMatch = picomatch(patterns, {
|
|
10
|
+
dot: true,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return isMatch(name);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const defaults = {
|
|
17
|
+
exclude: [],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const readConfig = once(() => {
|
|
21
|
+
const name = findUpSync('.nycrc.json');
|
|
22
|
+
|
|
23
|
+
if (!name)
|
|
24
|
+
return defaults;
|
|
25
|
+
|
|
26
|
+
const data = readFileSync(name, 'utf8');
|
|
27
|
+
return {
|
|
28
|
+
...defaults,
|
|
29
|
+
...parse(data),
|
|
30
|
+
};
|
|
31
|
+
});
|
package/lib/escover.js
CHANGED
|
@@ -2,21 +2,27 @@ import montag from 'montag';
|
|
|
2
2
|
import process from 'process';
|
|
3
3
|
|
|
4
4
|
import {instrument} from './instrument/index.js';
|
|
5
|
-
import {exclude} from './exclude.js';
|
|
6
5
|
import {exit} from './exit.js';
|
|
7
6
|
import {createFileEntry} from './c4.js';
|
|
7
|
+
import {
|
|
8
|
+
readConfig,
|
|
9
|
+
isExclude,
|
|
10
|
+
} from './config.js';
|
|
8
11
|
|
|
9
12
|
global.__createC4 = createFileEntry;
|
|
10
13
|
|
|
11
14
|
process.once('exit', exit);
|
|
12
15
|
const CWD = process.cwd();
|
|
13
16
|
|
|
17
|
+
const {exclude} = readConfig();
|
|
18
|
+
|
|
14
19
|
const EXCLUDE = [
|
|
15
|
-
'
|
|
16
|
-
'node_modules',
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
+
'**/*.spec.*',
|
|
21
|
+
'**/node_modules/**',
|
|
22
|
+
'**/fixture/**',
|
|
23
|
+
'**/.madrun.*',
|
|
24
|
+
'**/test/**',
|
|
25
|
+
...exclude,
|
|
20
26
|
];
|
|
21
27
|
|
|
22
28
|
export async function load(url, context, defaultLoad) {
|
|
@@ -33,7 +39,7 @@ export async function load(url, context, defaultLoad) {
|
|
|
33
39
|
source: rawSource,
|
|
34
40
|
};
|
|
35
41
|
|
|
36
|
-
if (
|
|
42
|
+
if (isExclude(url, EXCLUDE))
|
|
37
43
|
return {
|
|
38
44
|
format,
|
|
39
45
|
source: rawSource,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"mock-import": "^2.11.1",
|
|
43
43
|
"montag": "^1.2.1",
|
|
44
44
|
"once": "^1.4.0",
|
|
45
|
+
"picomatch": "^2.3.1",
|
|
45
46
|
"putout": "^24.0.2",
|
|
46
47
|
"table": "^6.8.0",
|
|
47
48
|
"try-catch": "^3.0.0",
|