escover 1.0.2 โ 1.1.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 +25 -0
- package/README.md +7 -1
- package/bin/escover.js +11 -0
- package/lib/c4.js +2 -2
- package/lib/cli/cli.js +54 -0
- package/lib/cli/version.js +12 -0
- package/lib/config.js +40 -0
- package/lib/escover.js +2 -2
- package/lib/exit.js +2 -5
- package/lib/instrument/plugin-mark/fixture/arrow-fix.js +2 -2
- package/lib/instrument/plugin-mark/fixture/assignment-fix.js +2 -1
- package/lib/instrument/plugin-mark/fixture/assignment.js +1 -0
- package/lib/instrument/plugin-mark/fixture/if-fix.js +6 -0
- package/lib/instrument/plugin-mark/fixture/if.js +6 -0
- package/lib/instrument/plugin-mark/fixture/logical-fix.js +2 -2
- package/lib/instrument/plugin-mark/fixture/mark-line-fix.js +11 -11
- package/lib/instrument/plugin-mark/fixture/new-fix.js +1 -1
- package/lib/instrument/plugin-mark/fixture/no-loc-fix.js +3 -3
- package/lib/instrument/plugin-mark/index.js +15 -10
- package/lib/instrument/plugin-mark/throw.js +17 -0
- package/lib/merge.js +44 -0
- package/lib/report.js +22 -22
- package/lib/transform.js +20 -0
- package/package.json +14 -2
- package/c4.json +0 -15
- package/coverage.json +0 -8
- package/lib/save.js +0 -26
package/ChangeLog
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
2022.01.11, v1.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- (escover) add bin
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.08, v1.0.5
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- escover: report
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
2022.01.08, v1.0.4
|
|
14
|
+
|
|
15
|
+
feature:
|
|
16
|
+
- escover: add support of AssignmentExpression
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
2022.01.08, v1.0.3
|
|
20
|
+
|
|
21
|
+
feature:
|
|
22
|
+
- escover: plugin-mark: add support ot ThrowStatement
|
|
23
|
+
- escover: add merger
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
2022.01.08, v1.0.2
|
|
2
27
|
|
|
3
28
|
fix:
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[CoverageURL]: https://coveralls.io/github/coderaiser/escover?branch=master
|
|
10
10
|
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/escover/badge.svg?branch=master&service=github
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Coverage for EcmaScript Modules based on ๐[`Putout`](https://github.com/coderaiser/putout).
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
@@ -19,6 +19,12 @@ npm i escover -g
|
|
|
19
19
|
|
|
20
20
|
Then run using:
|
|
21
21
|
|
|
22
|
+
```sh
|
|
23
|
+
escover npm test
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or as [loader](https://nodejs.org/dist/latest-v16.x/docs/api/esm.html#loaders):
|
|
27
|
+
|
|
22
28
|
```sh
|
|
23
29
|
NODE_OPTIONS="'--loader escover'" escover npm test
|
|
24
30
|
```
|
package/bin/escover.js
ADDED
package/lib/c4.js
CHANGED
|
@@ -5,10 +5,10 @@ export const createFileEntry = (url) => {
|
|
|
5
5
|
files.set(url, lines);
|
|
6
6
|
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
'๐งจ': (line, column) => {
|
|
9
9
|
lines.set(`${line}:${column}`, true);
|
|
10
10
|
},
|
|
11
|
-
init: (line, column) => {
|
|
11
|
+
'init': (line, column) => {
|
|
12
12
|
lines.set(`${line}:${column}`, false);
|
|
13
13
|
},
|
|
14
14
|
};
|
package/lib/cli/cli.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {promisify} from 'util';
|
|
2
|
+
import yargsParser from 'yargs-parser';
|
|
3
|
+
import _foreground from 'foreground-child';
|
|
4
|
+
|
|
5
|
+
import {version} from './version.js';
|
|
6
|
+
import {report} from '../report.js';
|
|
7
|
+
|
|
8
|
+
const foreground = promisify((cmd, fn) => {
|
|
9
|
+
_foreground(cmd, () => {
|
|
10
|
+
fn();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
process.env.ZENLOAD = 'escover,mock-import';
|
|
15
|
+
|
|
16
|
+
export const cli = async ({argv, exit, read}) => {
|
|
17
|
+
const args = yargsParser(argv.slice(2), {
|
|
18
|
+
boolean: [
|
|
19
|
+
'version',
|
|
20
|
+
],
|
|
21
|
+
alias: {
|
|
22
|
+
v: 'version',
|
|
23
|
+
},
|
|
24
|
+
configuration: {},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (args.version) {
|
|
28
|
+
console.log(`v${version()}`);
|
|
29
|
+
return exit();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const cmd = hideInstrumenterArgs(args);
|
|
33
|
+
|
|
34
|
+
if (!cmd.length)
|
|
35
|
+
return;
|
|
36
|
+
|
|
37
|
+
await foreground(cmd);
|
|
38
|
+
const coverage = read();
|
|
39
|
+
|
|
40
|
+
report(coverage);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function hideInstrumenterArgs(yargv) {
|
|
44
|
+
let argv = process.argv.slice(1);
|
|
45
|
+
|
|
46
|
+
argv = argv.slice(argv.indexOf(yargv._[0]));
|
|
47
|
+
|
|
48
|
+
if (argv[0][0] === '-') {
|
|
49
|
+
argv.unshift(process.execPath);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return argv;
|
|
53
|
+
}
|
|
54
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {readFileSync} from 'fs';
|
|
2
|
+
const {parse} = JSON;
|
|
3
|
+
|
|
4
|
+
const packageJson = new URL('../../package.json', import.meta.url);
|
|
5
|
+
|
|
6
|
+
export const version = () => {
|
|
7
|
+
const data = readFileSync(packageJson, 'utf8');
|
|
8
|
+
const {version} = parse(data);
|
|
9
|
+
|
|
10
|
+
return version;
|
|
11
|
+
};
|
|
12
|
+
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeFileSync,
|
|
3
|
+
readFileSync,
|
|
4
|
+
} from 'fs';
|
|
5
|
+
import {getFiles} from './c4.js';
|
|
6
|
+
import {transform} from './transform.js';
|
|
7
|
+
import {merge} from './merge.js';
|
|
8
|
+
import findCacheDir from 'find-cache-dir';
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
stringify,
|
|
12
|
+
parse,
|
|
13
|
+
} = JSON;
|
|
14
|
+
|
|
15
|
+
const NAME = 'escover';
|
|
16
|
+
const buildName = (a) => `${a}/${NAME}.json`;
|
|
17
|
+
|
|
18
|
+
export const write = () => {
|
|
19
|
+
const files = getFiles();
|
|
20
|
+
const parsed = transform(files);
|
|
21
|
+
const merged = merge(parsed);
|
|
22
|
+
const name = findCacheDir({
|
|
23
|
+
name: NAME,
|
|
24
|
+
create: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
writeFileSync(buildName(name), stringify(merged, null, 4));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const read = () => {
|
|
31
|
+
const name = findCacheDir({
|
|
32
|
+
name: NAME,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!name)
|
|
36
|
+
return null;
|
|
37
|
+
|
|
38
|
+
const data = readFileSync(buildName(name), 'utf8');
|
|
39
|
+
return parse(data);
|
|
40
|
+
};
|
package/lib/escover.js
CHANGED
|
@@ -8,6 +8,8 @@ import {createFileEntry} from './c4.js';
|
|
|
8
8
|
|
|
9
9
|
global.__createC4 = createFileEntry;
|
|
10
10
|
|
|
11
|
+
process.once('exit', exit);
|
|
12
|
+
|
|
11
13
|
export async function load(url, context, defaultLoad) {
|
|
12
14
|
const {format, source: rawSource} = await defaultLoad(url, context, defaultLoad);
|
|
13
15
|
|
|
@@ -33,5 +35,3 @@ export async function load(url, context, defaultLoad) {
|
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
process.once('exit', exit);
|
|
37
|
-
|
package/lib/exit.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const [error, {packageJson} = (__c4
|
|
1
|
+
const [error, {packageJson} = (__c4['๐งจ'](1, 14), {})] = (__c4['๐งจ'](1, 36), tryCatch(readPackageUpSync));
|
|
2
|
+
data += (__c4['๐งจ'](2, 0), 'fix:' + '\n');
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
if ((__c4
|
|
2
|
-
__c4
|
|
1
|
+
if ((__c4['๐งจ'](1, 4), a) || (__c4['๐งจ'](1, 9), b)) {
|
|
2
|
+
__c4['๐งจ'](1, 12);
|
|
3
3
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const a = () => {
|
|
2
|
-
a = 5;
|
|
3
|
-
__c4
|
|
2
|
+
a = (__c4['๐งจ'](2, 4), 5);
|
|
3
|
+
__c4['๐งจ'](3, 4), console.log(5);
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
function x() {
|
|
8
8
|
|
|
9
9
|
if (a > 2) {
|
|
10
|
-
__c4
|
|
10
|
+
__c4['๐งจ'](9, 14), a();
|
|
11
11
|
} else {
|
|
12
|
-
__c4
|
|
12
|
+
__c4['๐งจ'](10, 9), b();
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
for (const x of y) {
|
|
17
|
-
__c4
|
|
17
|
+
__c4['๐งจ'](13, 19);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const ax = ((__c4
|
|
21
|
-
const bx = (c, (__c4
|
|
20
|
+
const ax = ((__c4['๐งจ'](16, 12), a()), (__c4['๐งจ'](16, 17), b()));
|
|
21
|
+
const bx = (c, (__c4['๐งจ'](17, 15), d()));
|
|
22
22
|
|
|
23
|
-
if ((__c4
|
|
24
|
-
__c4
|
|
23
|
+
if ((__c4['๐งจ'](19, 4), a) || (__c4['๐งจ'](19, 9), b)) {
|
|
24
|
+
__c4['๐งจ'](19, 12);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
function x1(a, b = (__c4
|
|
29
|
-
__c4
|
|
28
|
+
function x1(a, b = (__c4['๐งจ'](23, 15), 5)) {
|
|
29
|
+
__c4['๐งจ'](23, 22);
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const files = (__c4
|
|
1
|
+
const files = (__c4['๐งจ'](1, 14), new Map());
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
__c4
|
|
1
|
+
__c4['๐งจ'](1, 0), cli({
|
|
2
2
|
stdout,
|
|
3
3
|
stderr,
|
|
4
4
|
exit,
|
|
5
|
-
cwd: (__c4
|
|
6
|
-
argv: (__c4
|
|
5
|
+
cwd: (__c4['๐งจ'](5, 9), process.cwd()),
|
|
6
|
+
argv: (__c4['๐งจ'](6, 10), process.argv.slice(2))
|
|
7
7
|
});
|
|
8
8
|
|
|
@@ -5,21 +5,20 @@ import {
|
|
|
5
5
|
} from 'putout';
|
|
6
6
|
import {addMarkToReturn} from './return.js';
|
|
7
7
|
import {addMarkToArrowFunction} from './arrow.js';
|
|
8
|
+
import {addMarkToThrow} from './throw.js';
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
NumericLiteral,
|
|
11
12
|
SequenceExpression,
|
|
12
13
|
BlockStatement,
|
|
13
|
-
ExpressionStatement,
|
|
14
14
|
} = types;
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
|
-
replaceWithMultiple,
|
|
18
17
|
replaceWith,
|
|
19
18
|
compareAny,
|
|
20
19
|
} = operator;
|
|
21
20
|
|
|
22
|
-
const LINE = '
|
|
21
|
+
const LINE = `__c4['๐งจ'](__l, __c)`;
|
|
23
22
|
const buildLineNode = template(LINE, {
|
|
24
23
|
placeholderPattern: /^__[a-z]$/,
|
|
25
24
|
});
|
|
@@ -81,11 +80,11 @@ export const fix = (path, {options}) => {
|
|
|
81
80
|
return;
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
if (path.isAssignmentPattern()) {
|
|
85
|
-
|
|
86
|
-
lineNode,
|
|
83
|
+
if (path.isAssignmentPattern() || path.isAssignmentExpression()) {
|
|
84
|
+
replaceWith(path.get('right'), SequenceExpression([
|
|
85
|
+
lineNode.expression,
|
|
87
86
|
node.right,
|
|
88
|
-
]);
|
|
87
|
+
]));
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
|
|
@@ -100,8 +99,12 @@ export const fix = (path, {options}) => {
|
|
|
100
99
|
if (path.isReturnStatement())
|
|
101
100
|
return addMarkToReturn(path, lineNode);
|
|
102
101
|
|
|
103
|
-
if (path.isArrowFunctionExpression())
|
|
102
|
+
if (path.isArrowFunctionExpression()) {
|
|
104
103
|
return addMarkToArrowFunction(path, lineNode);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (path.isThrowStatement())
|
|
107
|
+
return addMarkToThrow(path, lineNode);
|
|
105
108
|
|
|
106
109
|
replaceWith(path, BlockStatement([
|
|
107
110
|
node,
|
|
@@ -113,6 +116,7 @@ const EXCLUDE = [
|
|
|
113
116
|
`(${LINE}, __z)`,
|
|
114
117
|
`return (${LINE}, __z)`,
|
|
115
118
|
`return ${LINE}`,
|
|
119
|
+
`throw (${LINE}, __z)`,
|
|
116
120
|
];
|
|
117
121
|
|
|
118
122
|
export const exclude = () => EXCLUDE;
|
|
@@ -121,10 +125,11 @@ export const include = () => [
|
|
|
121
125
|
'CallExpression',
|
|
122
126
|
'NewExpression',
|
|
123
127
|
'ReturnStatement',
|
|
128
|
+
'ThrowStatement',
|
|
124
129
|
];
|
|
125
130
|
|
|
126
131
|
export const traverse = ({push}) => ({
|
|
127
|
-
AssignmentPattern(path) {
|
|
132
|
+
'AssignmentPattern|AssignmentExpression'(path) {
|
|
128
133
|
if (compareAny(path.get('right'), EXCLUDE))
|
|
129
134
|
return;
|
|
130
135
|
|
|
@@ -162,7 +167,7 @@ export const traverse = ({push}) => ({
|
|
|
162
167
|
const consequentPath = path.get('consequent');
|
|
163
168
|
const alternatePath = path.get('alternate');
|
|
164
169
|
|
|
165
|
-
if (!consequentPath.isBlockStatement())
|
|
170
|
+
if (!consequentPath.isBlockStatement() && !compareAny(consequentPath, EXCLUDE))
|
|
166
171
|
push(consequentPath);
|
|
167
172
|
|
|
168
173
|
if (!alternatePath.node)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
types,
|
|
3
|
+
operator,
|
|
4
|
+
} from 'putout';
|
|
5
|
+
const {SequenceExpression} = types;
|
|
6
|
+
|
|
7
|
+
const {replaceWith} = operator;
|
|
8
|
+
|
|
9
|
+
export const addMarkToThrow = (path, lineNode) => {
|
|
10
|
+
const argumentPath = path.get('argument');
|
|
11
|
+
|
|
12
|
+
return replaceWith(argumentPath, SequenceExpression([
|
|
13
|
+
lineNode.expression,
|
|
14
|
+
argumentPath.node,
|
|
15
|
+
]));
|
|
16
|
+
};
|
|
17
|
+
|
package/lib/merge.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const {entries} = Object;
|
|
2
|
+
|
|
3
|
+
export const merge = (files) => {
|
|
4
|
+
const deduplicator = {};
|
|
5
|
+
|
|
6
|
+
for (const {rawName, rawLines} of files) {
|
|
7
|
+
const name = cutQuery(rawName);
|
|
8
|
+
const lines = applyCoverage({
|
|
9
|
+
name,
|
|
10
|
+
rawLines,
|
|
11
|
+
deduplicator,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
deduplicator[name] = lines;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const list = [];
|
|
18
|
+
for (const [name, lines] of entries(deduplicator)) {
|
|
19
|
+
list.push({
|
|
20
|
+
name,
|
|
21
|
+
lines,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return list;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function applyCoverage({rawLines, name, deduplicator}) {
|
|
29
|
+
if (!deduplicator[name])
|
|
30
|
+
return rawLines;
|
|
31
|
+
|
|
32
|
+
const newLines = {};
|
|
33
|
+
|
|
34
|
+
for (const [line, value] of entries(rawLines))
|
|
35
|
+
newLines[line] = deduplicator[name][line] || value;
|
|
36
|
+
|
|
37
|
+
return newLines;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cutQuery(name) {
|
|
41
|
+
return name
|
|
42
|
+
.replace('file://', '')
|
|
43
|
+
.replace(/\?.*/, '');
|
|
44
|
+
}
|
package/lib/report.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const {parse} = JSON;
|
|
5
|
-
|
|
6
|
-
export const report = () => {
|
|
7
|
-
const coverageFile = parse(readFileSync('./coverage.json', 'utf8'));
|
|
2
|
+
const {entries} = Object;
|
|
8
3
|
|
|
4
|
+
export const report = (coverageFile) => {
|
|
9
5
|
const files = [];
|
|
10
6
|
const coverage = {
|
|
11
7
|
files,
|
|
12
8
|
coveredCount: 0,
|
|
13
9
|
uncoveredCount: 0,
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
console.log('#
|
|
11
|
+
|
|
12
|
+
console.log('# CAP version 13');
|
|
17
13
|
console.log('');
|
|
18
|
-
|
|
14
|
+
|
|
19
15
|
for (const {name, lines} of coverageFile) {
|
|
20
16
|
const uncoveredLines = [];
|
|
21
17
|
|
|
22
|
-
for (const [line, covered] of
|
|
18
|
+
for (const [line, covered] of entries(lines)) {
|
|
23
19
|
if (covered)
|
|
24
20
|
continue;
|
|
25
21
|
|
|
@@ -40,30 +36,34 @@ export const report = () => {
|
|
|
40
36
|
|
|
41
37
|
files.push(file);
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
|
|
44
40
|
for (const {name, covered, uncoveredLines} of files) {
|
|
45
41
|
if (!covered) {
|
|
46
42
|
console.log(`# ${name}`);
|
|
47
|
-
console.log('
|
|
43
|
+
console.log('๐งจ should be covered');
|
|
48
44
|
console.log('---');
|
|
49
|
-
console.log(`lines
|
|
45
|
+
console.log(`lines:`);
|
|
46
|
+
for (const line of uncoveredLines) {
|
|
47
|
+
console.log(`๏ธ- ${chalk.red(line)} at file://${name}:${line}`);
|
|
48
|
+
}
|
|
49
|
+
console.log('');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
if (coverage.uncoveredCount)
|
|
54
|
-
console.log('');
|
|
55
|
-
|
|
52
|
+
|
|
56
53
|
console.log(`1..${files.length}`);
|
|
57
54
|
console.log(`# files: ${files.length}`);
|
|
58
55
|
console.log(`# covered: ${coverage.coveredCount}`);
|
|
59
|
-
|
|
56
|
+
|
|
57
|
+
console.log('');
|
|
58
|
+
|
|
60
59
|
if (!coverage.uncoveredCount) {
|
|
61
|
-
console.log('');
|
|
62
|
-
console.log('# โ๏ธ ok');
|
|
60
|
+
console.log('#๏ธ ๐ด ok');
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
|
|
65
63
|
if (coverage.uncoveredCount) {
|
|
66
64
|
console.log(`# ๐งจ fail: ${coverage.uncoveredCount}`);
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
|
|
67
|
+
console.log('');
|
|
68
|
+
};
|
|
69
69
|
|
package/lib/transform.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const transform = (files) => {
|
|
2
|
+
const result = [];
|
|
3
|
+
|
|
4
|
+
for (const [rawName, places] of files.entries()) {
|
|
5
|
+
const rawLines = {};
|
|
6
|
+
|
|
7
|
+
for (const [place, covered] of places.entries()) {
|
|
8
|
+
const [line] = place.split(':');
|
|
9
|
+
|
|
10
|
+
rawLines[line] = covered;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
result.push({
|
|
14
|
+
rawName,
|
|
15
|
+
rawLines,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return result;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "escover",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"escover": "bin/escover.js"
|
|
10
|
+
},
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
10
13
|
"url": "git://github.com/coderaiser/escover.git"
|
|
@@ -15,8 +18,11 @@
|
|
|
15
18
|
"loader"
|
|
16
19
|
],
|
|
17
20
|
"scripts": {
|
|
21
|
+
"loader": "madrun loader",
|
|
18
22
|
"test": "madrun test",
|
|
23
|
+
"test:only": "madrun test:only",
|
|
19
24
|
"coverage": "madrun coverage",
|
|
25
|
+
"c4": "madrun c4",
|
|
20
26
|
"lint": "madrun lint",
|
|
21
27
|
"fresh:lint": "madrun fresh:lint",
|
|
22
28
|
"lint:fresh": "madrun lint:fresh",
|
|
@@ -30,9 +36,14 @@
|
|
|
30
36
|
},
|
|
31
37
|
"dependencies": {
|
|
32
38
|
"chalk": "^5.0.0",
|
|
39
|
+
"find-cache-dir": "^3.3.2",
|
|
40
|
+
"find-up": "^6.2.0",
|
|
41
|
+
"foreground-child": "^2.0.0",
|
|
33
42
|
"montag": "^1.2.1",
|
|
34
43
|
"once": "^1.4.0",
|
|
35
|
-
"putout": "^23.5.0"
|
|
44
|
+
"putout": "^23.5.0",
|
|
45
|
+
"try-catch": "^3.0.0",
|
|
46
|
+
"yargs-parser": "^21.0.0"
|
|
36
47
|
},
|
|
37
48
|
"engines": {
|
|
38
49
|
"node": ">=14"
|
|
@@ -41,6 +52,7 @@
|
|
|
41
52
|
"devDependencies": {
|
|
42
53
|
"@putout/test": "^4.1.0",
|
|
43
54
|
"c8": "^7.8.0",
|
|
55
|
+
"escover": ".",
|
|
44
56
|
"eslint": "^8.3.0",
|
|
45
57
|
"eslint-plugin-node": "^11.1.0",
|
|
46
58
|
"eslint-plugin-putout": "^12.2.0",
|
package/c4.json
DELETED
package/coverage.json
DELETED
package/lib/save.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {writeFileSync} from 'fs';
|
|
2
|
-
import {getFiles} from './c4.js';
|
|
3
|
-
|
|
4
|
-
const {stringify} = JSON;
|
|
5
|
-
|
|
6
|
-
export const save = () => {
|
|
7
|
-
const files = getFiles();
|
|
8
|
-
const report = [];
|
|
9
|
-
for (const [name, places] of files.entries()) {
|
|
10
|
-
const lines = {};
|
|
11
|
-
const current = {
|
|
12
|
-
name,
|
|
13
|
-
lines,
|
|
14
|
-
};
|
|
15
|
-
for (const [place, covered] of places.entries()) {
|
|
16
|
-
const [line] = place.split(':');
|
|
17
|
-
|
|
18
|
-
lines[line] = covered;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
report.push(current);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
writeFileSync('./coverage.json', stringify(report, null, 4));
|
|
25
|
-
};
|
|
26
|
-
|