escover 1.10.0 → 1.11.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 CHANGED
@@ -1,3 +1,10 @@
1
+ 2022.01.19, v1.11.0
2
+
3
+ feature:
4
+ - escover: mark: add support of continue
5
+ - escover: coverage-file: read -> readCoverage
6
+
7
+
1
8
  2022.01.19, v1.10.0
2
9
 
3
10
  feature:
package/bin/escover.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import {cli} from '../lib/cli/cli.js';
4
- import {read} from '../lib/coverage-file/coverage-file.js';
4
+ import {readCoverage} from '../lib/coverage-file/coverage-file.js';
5
+ import {readConfig} from '../lib/config.js';
5
6
 
6
7
  cli({
7
8
  argv: process.argv,
8
9
  exit: process.exit,
9
- read,
10
+ readCoverage,
11
+ readConfig,
10
12
  });
11
13
 
package/lib/cli/cli.js CHANGED
@@ -8,7 +8,7 @@ import reportFiles from '../formatters/files.js';
8
8
 
9
9
  const {ESCOVER_FORMAT, NODE_OPTIONS = ''} = process.env;
10
10
 
11
- export const cli = ({argv, exit, read}) => {
11
+ export const cli = ({argv, exit, readCoverage}) => {
12
12
  const args = yargsParser(argv.slice(2), {
13
13
  string: [
14
14
  'format',
@@ -36,7 +36,7 @@ export const cli = ({argv, exit, read}) => {
36
36
  execute('"' + cmd.join(`" "`) + '"', exit);
37
37
  }
38
38
 
39
- const coverage = read();
39
+ const coverage = readCoverage();
40
40
 
41
41
  let output = '';
42
42
 
@@ -16,7 +16,7 @@ const {
16
16
  const NAME = 'escover';
17
17
  const buildName = (a) => `${a}/${NAME}.json`;
18
18
 
19
- export const write = () => {
19
+ export const writeCoverage = () => {
20
20
  const files = getFileEntries();
21
21
 
22
22
  if (!files.size)
@@ -33,7 +33,7 @@ export const write = () => {
33
33
  writeFileSync(buildName(name), stringify(merged, null, 4));
34
34
  };
35
35
 
36
- export const read = () => {
36
+ export const readCoverage = () => {
37
37
  const name = findCacheDir({
38
38
  name: NAME,
39
39
  });
@@ -0,0 +1,17 @@
1
+ const {entries} = Object;
2
+
3
+ export const createLcov = (files) => {
4
+ const result = [];
5
+
6
+ for (const {name, lines} of files) {
7
+ result.push(`SF:${name}`);
8
+ for (const [line, covered] of entries(lines)) {
9
+ const count = covered ? 1 : 0;
10
+ result.push(`DA:${line},${count}`);
11
+ }
12
+
13
+ result.push('end_of_record');
14
+ }
15
+
16
+ return result.join('\n');
17
+ };
package/lib/exit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import once from 'once';
2
- import {write} from './coverage-file/coverage-file.js';
2
+ import {writeCoverage} from './coverage-file/coverage-file.js';
3
3
 
4
4
  export const exit = once(() => {
5
- write();
5
+ writeCoverage();
6
6
  });
@@ -0,0 +1,10 @@
1
+ import {operator} from 'putout';
2
+ const {replaceWithMultiple} = operator;
3
+
4
+ export const addMarkToContinue = (path, lineNode) => {
5
+ return replaceWithMultiple(path, [
6
+ lineNode,
7
+ path.node,
8
+ ]);
9
+ };
10
+
@@ -3,9 +3,11 @@ import {
3
3
  types,
4
4
  operator,
5
5
  } from 'putout';
6
+
6
7
  import {addMarkToReturn} from './return.js';
7
8
  import {addMarkToArrowFunction} from './arrow.js';
8
9
  import {addMarkToThrow} from './throw.js';
10
+ import {addMarkToContinue} from './continue.js';
9
11
 
10
12
  const {
11
13
  NumericLiteral,
@@ -16,6 +18,7 @@ const {
16
18
  const {
17
19
  replaceWith,
18
20
  compareAny,
21
+ compare,
19
22
  } = operator;
20
23
 
21
24
  const LINE = `__c4['🧨'](__l, __c)`;
@@ -93,13 +96,15 @@ export const fix = (path, {options}) => {
93
96
  if (path.isReturnStatement())
94
97
  return addMarkToReturn(path, lineNode);
95
98
 
96
- if (path.isArrowFunctionExpression()) {
99
+ if (path.isArrowFunctionExpression())
97
100
  return addMarkToArrowFunction(path, lineNode);
98
- }
99
101
 
100
102
  if (path.isThrowStatement())
101
103
  return addMarkToThrow(path, lineNode);
102
104
 
105
+ if (path.isContinueStatement())
106
+ return addMarkToContinue(path, lineNode);
107
+
103
108
  replaceWith(path, BlockStatement([
104
109
  node,
105
110
  ]));
@@ -135,6 +140,17 @@ export const traverse = ({push}) => ({
135
140
 
136
141
  push(path);
137
142
  },
143
+ ContinueStatement(path) {
144
+ if (!path.parentPath.isBlockStatement())
145
+ return;
146
+
147
+ const {body} = path.parentPath.node;
148
+
149
+ if (compare(body[0], LINE))
150
+ return;
151
+
152
+ push(path);
153
+ },
138
154
  LogicalExpression(path) {
139
155
  if (compareAny(path.get('left'), EXCLUDE))
140
156
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.10.0",
3
+ "version": "1.11.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",
@@ -27,6 +27,7 @@
27
27
  "fix:lint": "madrun fix:lint",
28
28
  "report": "madrun report",
29
29
  "watcher": "madrun watcher",
30
+ "watch:test": "madrun watch:test",
30
31
  "watch:lint": "madrun watch:lint",
31
32
  "watch:tape": "madrun watch:tape",
32
33
  "prewisdom": "madrun prewisdom"
@@ -40,6 +41,7 @@
40
41
  "once": "^1.4.0",
41
42
  "picomatch": "^2.3.1",
42
43
  "putout": "^24.0.2",
44
+ "strip-ansi": "^7.0.1",
43
45
  "table": "^6.8.0",
44
46
  "try-catch": "^3.0.0",
45
47
  "yargs-parser": "^21.0.0",