escover 1.8.1 → 1.9.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.9.0
2
+
3
+ feature:
4
+ - escover: formatters: files: add ability to cut lines, when count more then 10
5
+ - escover: formatters returning a string
6
+
7
+
1
8
  2022.01.19, v1.8.1
2
9
 
3
10
  fix:
package/lib/cli/cli.js CHANGED
@@ -38,10 +38,14 @@ export const cli = ({argv, exit, read}) => {
38
38
 
39
39
  const coverage = read();
40
40
 
41
+ let output = '';
42
+
41
43
  if (args.format === 'lines')
42
- return reportLines(coverage);
44
+ output = reportLines(coverage);
45
+ else
46
+ output = reportFiles(coverage);
43
47
 
44
- reportFiles(coverage);
48
+ process.stdout.write(output);
45
49
  };
46
50
 
47
51
  function execute(cmd, exit) {
@@ -19,7 +19,7 @@ export default (coverageFile) => {
19
19
  ];
20
20
 
21
21
  for (const {filename, covered, lines, percentLines} of files) {
22
- const uncoveredLines = lines.join(', ');
22
+ const uncoveredLines = formatLines(lines);
23
23
 
24
24
  if (covered) {
25
25
  tableData.push([chalk.green(filename), chalk.green(percentLines), '']);
@@ -29,7 +29,7 @@ export default (coverageFile) => {
29
29
  tableData.push([chalk.red(filename), chalk.red(percentLines), chalk.red(uncoveredLines)]);
30
30
  }
31
31
 
32
- process.stdout.write(table(tableData, {
32
+ return table(tableData, {
33
33
  drawHorizontalLine: (raw) => {
34
34
  return !raw || raw === 1 || raw === files.length + 1;
35
35
  },
@@ -46,9 +46,19 @@ export default (coverageFile) => {
46
46
  joinJoin: '|',
47
47
  bodyJoin: '|',
48
48
  },
49
- }));
49
+ });
50
50
  };
51
51
 
52
+ export function formatLines(array) {
53
+ console.log(array);
54
+ const lines = array.slice(0, 10).join(', ');
55
+
56
+ if (array.length <= 10)
57
+ return lines;
58
+
59
+ return `${lines}...`;
60
+ }
61
+
52
62
  function parseUncoveredLines(lines) {
53
63
  const uncoveredLines = [];
54
64
 
@@ -1,7 +1,10 @@
1
1
  import chalk from 'chalk';
2
2
  const {entries} = Object;
3
3
 
4
+ const createOut = (output) => (a) => output.push(a);
4
5
  export default (coverageFile) => {
6
+ const output = [];
7
+ const out = createOut(output);
5
8
  const files = [];
6
9
  const coverage = {
7
10
  files,
@@ -9,8 +12,8 @@ export default (coverageFile) => {
9
12
  uncoveredCount: 0,
10
13
  };
11
14
 
12
- console.log('# CAP version 13');
13
- console.log('');
15
+ out('# CAP version 13');
16
+ out('');
14
17
 
15
18
  for (const {name, lines} of coverageFile) {
16
19
  const uncoveredLines = [];
@@ -39,31 +42,33 @@ export default (coverageFile) => {
39
42
 
40
43
  for (const {name, covered, uncoveredLines} of files) {
41
44
  if (!covered) {
42
- console.log(`# ${name}`);
43
- console.log('🧨 should be covered');
44
- console.log('---');
45
- console.log(`lines:`);
45
+ out(`# ${name}`);
46
+ out('🧨 should be covered');
47
+ out('---');
48
+ out(`lines:`);
46
49
  for (const line of uncoveredLines) {
47
- console.log(`️- ${chalk.red(line)} at file://${name}:${line}`);
50
+ out(`️- ${chalk.red(line)} at file://${name}:${line}`);
48
51
  }
49
- console.log('');
52
+ out('');
50
53
  }
51
54
  }
52
55
 
53
- console.log(`1..${files.length}`);
54
- console.log(`# files: ${files.length}`);
55
- console.log(`# covered: ${coverage.coveredCount}`);
56
+ out(`1..${files.length}`);
57
+ out(`# files: ${files.length}`);
58
+ out(`# covered: ${coverage.coveredCount}`);
56
59
 
57
- console.log('');
60
+ out('');
58
61
 
59
62
  if (!coverage.uncoveredCount) {
60
- console.log('#️ 🌴 ok');
63
+ out('#️ 🌴 ok');
61
64
  }
62
65
 
63
66
  if (coverage.uncoveredCount) {
64
- console.log(`# 🧨 fail: ${coverage.uncoveredCount}`);
67
+ out(`# 🧨 fail: ${coverage.uncoveredCount}`);
65
68
  }
66
69
 
67
- console.log('');
70
+ out('');
71
+
72
+ return output.join('\n');
68
73
  };
69
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.8.1",
3
+ "version": "1.9.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",
@@ -19,21 +19,17 @@
19
19
  "loader"
20
20
  ],
21
21
  "scripts": {
22
- "loader": "madrun loader",
23
22
  "test": "madrun test",
24
- "test:only": "madrun test:only",
25
23
  "coverage": "madrun coverage",
26
- "c4": "madrun c4",
27
24
  "lint": "madrun lint",
28
25
  "fresh:lint": "madrun fresh:lint",
29
26
  "lint:fresh": "madrun lint:fresh",
30
27
  "fix:lint": "madrun fix:lint",
31
28
  "report": "madrun report",
32
29
  "watcher": "madrun watcher",
33
- "watch:test": "madrun watch:test",
34
30
  "watch:lint": "madrun watch:lint",
35
31
  "watch:tape": "madrun watch:tape",
36
- "watch:coverage": "madrun watch:coverage"
32
+ "prewisdom": "madrun prewisdom"
37
33
  },
38
34
  "dependencies": {
39
35
  "chalk": "^5.0.0",