escover 1.9.0 → 1.10.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,9 @@
1
+ 2022.01.19, v1.10.0
2
+
3
+ feature:
4
+ - escover: add .. when to many lines to display
5
+
6
+
1
7
  2022.01.19, v1.9.0
2
8
 
3
9
  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/coverage-file.js';
4
+ import {read} from '../lib/coverage-file/coverage-file.js';
5
5
 
6
6
  cli({
7
7
  argv: process.argv,
@@ -1,12 +1,12 @@
1
- import tryCatch from 'try-catch';
2
1
  import {
3
2
  writeFileSync,
4
3
  readFileSync,
5
4
  } from 'fs';
6
- import {getFileEntries} from './c4.js';
7
- import {transform} from './transform.js';
8
- import {merge} from './merge.js';
9
- import findCacheDir from 'find-cache-dir';
5
+ import tryCatch from 'try-catch';
6
+ import {getFileEntries} from '../c4.js';
7
+ import {transform} from '../transform.js';
8
+ import {merge} from '../merge.js';
9
+ import {findCacheDir} from './find-cache-dir.js';
10
10
 
11
11
  const {
12
12
  stringify,
@@ -0,0 +1,14 @@
1
+ import {join} from 'path';
2
+ import {cwd} from 'process';
3
+ import {mkdirSync} from 'fs';
4
+
5
+ export function findCacheDir() {
6
+ const name = join(cwd(), 'coverage');
7
+
8
+ mkdirSync(name, {
9
+ recursive: true,
10
+ });
11
+
12
+ return name;
13
+ }
14
+
package/lib/exit.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import once from 'once';
2
- import {write} from './coverage-file.js';
2
+ import {write} from './coverage-file/coverage-file.js';
3
3
 
4
4
  export const exit = once(() => {
5
5
  write();
@@ -50,13 +50,13 @@ export default (coverageFile) => {
50
50
  };
51
51
 
52
52
  export function formatLines(array) {
53
- console.log(array);
54
53
  const lines = array.slice(0, 10).join(', ');
55
54
 
56
55
  if (array.length <= 10)
57
56
  return lines;
58
57
 
59
- return `${lines}...`;
58
+ const latest = array[array.length - 1];
59
+ return `${lines}..${latest}`;
60
60
  }
61
61
 
62
62
  function parseUncoveredLines(lines) {
@@ -79,11 +79,12 @@ function parseCoverageFile(coverageFile) {
79
79
  const uncoveredLines = parseUncoveredLines(lines);
80
80
 
81
81
  const linesCount = keys(lines).length;
82
- const percentLines = getPercentLines(linesCount, uncoveredLines);
82
+ const uncoveredLinesCount = uncoveredLines.length;
83
+ const percentLines = getLinesPercent(linesCount, uncoveredLinesCount);
83
84
 
84
85
  files.push({
85
86
  filename,
86
- covered: !uncoveredLines.length,
87
+ covered: !uncoveredLinesCount,
87
88
  lines: uncoveredLines,
88
89
  percentLines,
89
90
  });
@@ -92,9 +93,9 @@ function parseCoverageFile(coverageFile) {
92
93
  return files;
93
94
  }
94
95
 
95
- function getPercentLines(linesCount, uncoveredLines) {
96
+ export function getLinesPercent(linesCount, uncoveredLinesCount) {
96
97
  if (!linesCount)
97
98
  return 100;
98
99
 
99
- return 100 - Math.round(100 / linesCount * uncoveredLines.length);
100
+ return 100 - Math.round(100 / linesCount * uncoveredLinesCount);
100
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.9.0",
3
+ "version": "1.10.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",