escover 1.7.0 → 1.8.1

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,30 @@
1
+ 2022.01.19, v1.8.1
2
+
3
+ fix:
4
+ - npmignore: add example
5
+
6
+
7
+ 2022.01.19, v1.8.0
8
+
9
+ fix:
10
+ - chore: instrument: rm useless fixture
11
+
12
+ feature:
13
+ - escover: when one of expressions lin line not covered - line not covered
14
+
15
+
16
+ 2022.01.18, v1.7.2
17
+
18
+ feature:
19
+ - escover: config: isExclude: add ability to drop stars
20
+
21
+
22
+ 2022.01.17, v1.7.1
23
+
24
+ fix:
25
+ - escover: config: rm once
26
+
27
+
1
28
  2022.01.17, v1.7.0
2
29
 
3
30
  feature:
package/README.md CHANGED
@@ -47,17 +47,13 @@ escover npm test
47
47
 
48
48
  ## Config
49
49
 
50
- `exclude` section of configuration file `.nyrc.json` supported.
50
+ `exclude` section of configuration file `.nyrc.json` supported.
51
51
 
52
52
  ## How it looks like?
53
53
 
54
54
  When everything is covered:
55
55
 
56
- ![image](https://user-images.githubusercontent.com/1573141/147943954-ef708577-2856-4de0-9397-dead487b8c08.png)
57
-
58
- When some lines missing coverage:
59
-
60
- ![image](https://user-images.githubusercontent.com/1573141/147944130-9b901646-05ff-4a76-86c9-30631b0a0dd4.png)
56
+ ![image](https://user-images.githubusercontent.com/1573141/149822261-ff9bc3b4-6ee4-452c-9ada-3cc922b630ec.png)
61
57
 
62
58
  ## What if I want to use 🎩`ESCover` with `mock-import`?
63
59
 
package/lib/config.js CHANGED
@@ -1,12 +1,23 @@
1
1
  import {readFileSync} from 'fs';
2
- import once from 'once';
3
2
  import picomatch from 'picomatch';
4
3
  import {findUpSync} from 'find-up';
5
4
 
6
5
  const {parse} = JSON;
7
6
 
7
+ const addStars = (patterns) => {
8
+ const result = [];
9
+ for (const pattern of patterns) {
10
+ result.push(...[
11
+ `**/${pattern}/**`,
12
+ pattern,
13
+ ]);
14
+ }
15
+
16
+ return result;
17
+ };
18
+
8
19
  export const isExclude = (name, patterns) => {
9
- const isMatch = picomatch(patterns, {
20
+ const isMatch = picomatch(addStars(patterns), {
10
21
  dot: true,
11
22
  });
12
23
 
@@ -17,7 +28,7 @@ const defaults = {
17
28
  exclude: [],
18
29
  };
19
30
 
20
- export const readConfig = once(() => {
31
+ export const readConfig = () => {
21
32
  const name = findUpSync('.nycrc.json');
22
33
 
23
34
  if (!name)
@@ -28,4 +39,4 @@ export const readConfig = once(() => {
28
39
  ...defaults,
29
40
  ...parse(data),
30
41
  };
31
- });
42
+ };
package/lib/transform.js CHANGED
@@ -1,17 +1,13 @@
1
1
  const sort = (a) => new Map(Array.from(a.entries()).sort());
2
2
 
3
+ const isBool = (a) => typeof a === 'boolean';
4
+
3
5
  export const transform = (files) => {
4
6
  const result = [];
5
7
  const sorted = sort(files);
6
8
 
7
9
  for (const [rawName, places] of sorted.entries()) {
8
- const rawLines = {};
9
-
10
- for (const [place, covered] of places.entries()) {
11
- const [line] = place.split(':');
12
-
13
- rawLines[line] = covered;
14
- }
10
+ const rawLines = mergeLines(places);
15
11
 
16
12
  result.push({
17
13
  rawName,
@@ -22,3 +18,20 @@ export const transform = (files) => {
22
18
  return result;
23
19
  };
24
20
 
21
+ function mergeLines(places) {
22
+ const result = {};
23
+
24
+ for (const [place, covered] of places.entries()) {
25
+ const [line] = place.split(':');
26
+
27
+ if (isBool(result[line])) {
28
+ result[line] &= covered;
29
+ continue;
30
+ }
31
+
32
+ result[line] = covered;
33
+ }
34
+
35
+ return result;
36
+ }
37
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
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",
@@ -1,4 +0,0 @@
1
- export const sum = (a, b) => a + b;
2
-
3
- // export const mul = (a, b) => a * b;
4
-