escover 1.2.3 โ†’ 1.3.3

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.3
2
+
3
+ feature:
4
+ - escover: exclude not from current path
5
+
6
+
7
+ 2022.01.15, v1.3.2
8
+
9
+ fix:
10
+ - escover: rm console.log
11
+
12
+
13
+ 2022.01.15, v1.3.1
14
+
15
+ fix:
16
+ - escover: do not write coverage when empty
17
+
18
+ feature:
19
+ - escover: add ability to get coverage of itself
20
+
21
+
22
+ 2022.01.15, v1.3.0
23
+
24
+ feature:
25
+ - escover: exclude test
26
+ - escover: config -> coverage
27
+
28
+
1
29
  2022.01.15, v1.2.3
2
30
 
3
31
  fix:
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
@@ -9,6 +9,15 @@ import {createFileEntry} from './c4.js';
9
9
  global.__createC4 = createFileEntry;
10
10
 
11
11
  process.once('exit', exit);
12
+ const CWD = process.cwd();
13
+
14
+ const EXCLUDE = [
15
+ '.spec.',
16
+ 'node_modules',
17
+ '/fixture/',
18
+ '.madrun.',
19
+ '/test/',
20
+ ];
12
21
 
13
22
  export async function load(url, context, defaultLoad) {
14
23
  const {format, source: rawSource} = await defaultLoad(url, context, defaultLoad);
@@ -18,7 +27,13 @@ export async function load(url, context, defaultLoad) {
18
27
  format,
19
28
  };
20
29
 
21
- if (exclude(url, ['.spec.', 'node_modules', '/fixture/', '.madrun.']))
30
+ if (!url.includes(CWD))
31
+ return {
32
+ format,
33
+ source: rawSource,
34
+ };
35
+
36
+ if (exclude(url, EXCLUDE))
22
37
  return {
23
38
  format,
24
39
  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),
@@ -35,24 +35,18 @@ function getLineNode(__c4, {line, column}) {
35
35
  export const report = () => 'Mark line';
36
36
 
37
37
  export const fix = (path, {options}) => {
38
- const {
39
- parentPath,
40
- node,
41
- } = path;
38
+ const {node} = path;
42
39
 
43
- const {start} = path.node.loc || parentPath.node.loc || {};
44
-
45
- if (!start)
46
- return;
40
+ const {start} = path.node.loc;
47
41
 
48
42
  const {
49
- __c4 = {
43
+ c4 = {
50
44
  mark: () => {},
51
45
  init: () => {},
52
46
  },
53
47
  } = options;
54
48
 
55
- const lineNode = getLineNode(__c4, start);
49
+ const lineNode = getLineNode(c4, start);
56
50
 
57
51
  if (path.isBlockStatement()) {
58
52
  path.node.body.unshift(lineNode);
@@ -74,7 +68,7 @@ export const fix = (path, {options}) => {
74
68
  path.node.left,
75
69
  ]));
76
70
  replaceWith(path.get('right'), SequenceExpression([
77
- getLineNode(__c4, path.node.right.loc.start).expression,
71
+ getLineNode(c4, path.node.right.loc.start).expression,
78
72
  path.node.right,
79
73
  ]));
80
74
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.2.3",
3
+ "version": "1.3.3",
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",
@@ -54,7 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@putout/test": "^4.1.0",
56
56
  "c8": "^7.8.0",
57
- "escover": ".",
57
+ "escover": "^1.0.0",
58
58
  "eslint": "^8.3.0",
59
59
  "eslint-plugin-node": "^11.1.0",
60
60
  "eslint-plugin-putout": "^13.0.1",