escover 1.2.2 โ†’ 1.3.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 CHANGED
@@ -1,3 +1,31 @@
1
+ 2022.01.15, v1.3.2
2
+
3
+ fix:
4
+ - escover: rm console.log
5
+
6
+
7
+ 2022.01.15, v1.3.1
8
+
9
+ fix:
10
+ - escover: do not write coverage when empty
11
+
12
+ feature:
13
+ - escover: add ability to get coverage of itself
14
+
15
+
16
+ 2022.01.15, v1.3.0
17
+
18
+ feature:
19
+ - escover: exclude test
20
+ - escover: config -> coverage
21
+
22
+
23
+ 2022.01.15, v1.2.3
24
+
25
+ fix:
26
+ - escover: mock-import: devDependency -> dependency
27
+
28
+
1
29
  2022.01.15, v1.2.2
2
30
 
3
31
  feature:
package/bin/escover.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import {cli} from '../lib/cli/cli.js';
4
- import {read} from '../lib/config.js';
4
+ import {read} from '../lib/coverage.js';
5
5
 
6
6
  cli({
7
7
  argv: process.argv,
package/lib/c4.js CHANGED
@@ -1,8 +1,8 @@
1
- const files = new Map();
1
+ export const __fileEntries = new Map();
2
2
 
3
3
  export const createFileEntry = (url) => {
4
- const lines = files.get(url) || new Map();
5
- files.set(url, lines);
4
+ const lines = __fileEntries.get(url) || new Map();
5
+ __fileEntries.set(url, lines);
6
6
 
7
7
  return {
8
8
  '๐Ÿงจ': (line, column) => {
@@ -14,4 +14,4 @@ export const createFileEntry = (url) => {
14
14
  };
15
15
  };
16
16
 
17
- export const getFiles = () => files;
17
+ export const getFileEntries = () => __fileEntries;
@@ -3,7 +3,7 @@ import {
3
3
  writeFileSync,
4
4
  readFileSync,
5
5
  } from 'fs';
6
- import {getFiles} from './c4.js';
6
+ import {getFileEntries} from './c4.js';
7
7
  import {transform} from './transform.js';
8
8
  import {merge} from './merge.js';
9
9
  import findCacheDir from 'find-cache-dir';
@@ -17,7 +17,11 @@ const NAME = 'escover';
17
17
  const buildName = (a) => `${a}/${NAME}.json`;
18
18
 
19
19
  export const write = () => {
20
- const files = getFiles();
20
+ const files = getFileEntries();
21
+
22
+ if (!files.size)
23
+ return;
24
+
21
25
  const parsed = transform(files);
22
26
  const merged = merge(parsed);
23
27
  const name = findCacheDir({
package/lib/escover.js CHANGED
@@ -10,6 +10,14 @@ global.__createC4 = createFileEntry;
10
10
 
11
11
  process.once('exit', exit);
12
12
 
13
+ const EXCLUDE = [
14
+ '.spec.',
15
+ 'node_modules',
16
+ '/fixture/',
17
+ '.madrun.',
18
+ '/test/',
19
+ ];
20
+
13
21
  export async function load(url, context, defaultLoad) {
14
22
  const {format, source: rawSource} = await defaultLoad(url, context, defaultLoad);
15
23
 
@@ -18,7 +26,7 @@ export async function load(url, context, defaultLoad) {
18
26
  format,
19
27
  };
20
28
 
21
- if (exclude(url, ['.spec.', 'node_modules', '/fixture/', '.madrun.']))
29
+ if (exclude(url, EXCLUDE))
22
30
  return {
23
31
  format,
24
32
  source: rawSource,
package/lib/exit.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import once from 'once';
2
- import {write} from './config.js';
2
+ import {write} from './coverage.js';
3
3
 
4
4
  export const exit = once(() => {
5
5
  write();
@@ -3,11 +3,11 @@ import putout, {} from 'putout';
3
3
  import * as mark from './plugin-mark/index.js';
4
4
 
5
5
  export const instrument = (url, source) => {
6
- const __c4 = global.__createC4(url);
6
+ const c4 = global.__createC4(url);
7
7
  const options = {
8
8
  rules: {
9
9
  mark: ['on', {
10
- __c4,
10
+ c4,
11
11
  }],
12
12
  },
13
13
  plugins: [
@@ -23,8 +23,8 @@ const buildLineNode = template(LINE, {
23
23
  placeholderPattern: /^__[a-z]$/,
24
24
  });
25
25
 
26
- function getLineNode(__c4, {line, column}) {
27
- __c4.init(line, column);
26
+ function getLineNode(c4, {line, column}) {
27
+ c4.init(line, column);
28
28
 
29
29
  return buildLineNode({
30
30
  __l: NumericLiteral(line),
@@ -46,13 +46,13 @@ export const fix = (path, {options}) => {
46
46
  return;
47
47
 
48
48
  const {
49
- __c4 = {
49
+ c4 = {
50
50
  mark: () => {},
51
51
  init: () => {},
52
52
  },
53
53
  } = options;
54
54
 
55
- const lineNode = getLineNode(__c4, start);
55
+ const lineNode = getLineNode(c4, start);
56
56
 
57
57
  if (path.isBlockStatement()) {
58
58
  path.node.body.unshift(lineNode);
@@ -74,7 +74,7 @@ export const fix = (path, {options}) => {
74
74
  path.node.left,
75
75
  ]));
76
76
  replaceWith(path.get('right'), SequenceExpression([
77
- getLineNode(__c4, path.node.right.loc.start).expression,
77
+ getLineNode(c4, path.node.right.loc.start).expression,
78
78
  path.node.right,
79
79
  ]));
80
80
  return;
@@ -99,9 +99,8 @@ export const fix = (path, {options}) => {
99
99
  if (path.isReturnStatement())
100
100
  return addMarkToReturn(path, lineNode);
101
101
 
102
- if (path.isArrowFunctionExpression()) {
102
+ if (path.isArrowFunctionExpression())
103
103
  return addMarkToArrowFunction(path, lineNode);
104
- }
105
104
 
106
105
  if (path.isThrowStatement())
107
106
  return addMarkToThrow(path, lineNode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.2.2",
3
+ "version": "1.3.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",
@@ -39,6 +39,7 @@
39
39
  "chalk": "^5.0.0",
40
40
  "find-cache-dir": "^3.3.2",
41
41
  "find-up": "^6.2.0",
42
+ "mock-import": "^2.11.1",
42
43
  "montag": "^1.2.1",
43
44
  "once": "^1.4.0",
44
45
  "putout": "^24.0.2",
@@ -58,7 +59,6 @@
58
59
  "eslint-plugin-node": "^11.1.0",
59
60
  "eslint-plugin-putout": "^13.0.1",
60
61
  "madrun": "^8.8.1",
61
- "mock-import": "^2.11.1",
62
62
  "supertape": "^6.0.5"
63
63
  }
64
64
  }