escover 3.5.0 → 3.5.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,8 @@
1
+ 2023.07.31, v3.5.1
2
+
3
+ fix:
4
+ - ba6e405 escover: write coverage on exit -> write coverage each time
5
+
1
6
  2023.07.31, v3.5.0
2
7
 
3
8
  fix:
package/lib/cli/cli.js CHANGED
@@ -4,6 +4,7 @@ import yargsParser from 'yargs-parser';
4
4
  import {version} from './version.js';
5
5
  import reportLines from '../formatters/lines.js';
6
6
  import reportFiles from '../formatters/files.js';
7
+ import {exit as mainExit} from '../exit.js';
7
8
 
8
9
  const {ESCOVER_FORMAT} = process.env;
9
10
 
@@ -30,7 +31,7 @@ export const cli = ({argv, exit, readCoverage}) => {
30
31
  const cmd = argv.slice(2);
31
32
 
32
33
  if (cmd.length) {
33
- execute(`"${cmd.join('" "')}"`, exit);
34
+ execute(`"${cmd.join('" "')}"`, () => {});
34
35
  }
35
36
 
36
37
  const coverage = readCoverage();
@@ -45,7 +46,7 @@ export const cli = ({argv, exit, readCoverage}) => {
45
46
  process.stdout.write(output);
46
47
  };
47
48
 
48
- export const isSuccess = (error) => error?.status === Number(process.env.ESCOVER_SUCCESS_EXIT_CODE);
49
+ export const isSuccess = (error) => !error || error?.status === Number(process.env.ESCOVER_SUCCESS_EXIT_CODE);
49
50
 
50
51
  function execute(cmd, exit) {
51
52
  const [error] = tryCatch(execSync, cmd, {
@@ -57,8 +58,9 @@ function execute(cmd, exit) {
57
58
  },
58
59
  });
59
60
 
60
- if (isSuccess(error))
61
+ if (isSuccess(error)) {
61
62
  return exit(0);
63
+ }
62
64
 
63
65
  if (error) {
64
66
  console.error(error.message);
package/lib/escover.js CHANGED
@@ -7,8 +7,7 @@ import {
7
7
  readConfig,
8
8
  isExclude,
9
9
  } from './config.js';
10
-
11
- process.once('exit', exit);
10
+ import {writeCoverage} from './coverage-file/coverage-file.js';
12
11
 
13
12
  global.__createC4 = createFileEntry;
14
13
 
@@ -38,16 +37,15 @@ export function globalPreload({port}) {
38
37
  if (loader !== 'escover')
39
38
  return;
40
39
 
41
- if (type === 'exit')
42
- return exit();
43
-
44
40
  const c4 = createFileEntry(url);
45
41
 
46
42
  if (type === 'set')
47
- return c4['🧨'](line, column);
43
+ c4['🧨'](line, column);
48
44
 
49
45
  if (type === 'init')
50
- return c4.init(line, column);
46
+ c4.init(line, column);
47
+
48
+ writeCoverage();
51
49
  };
52
50
 
53
51
  return `(${escover})();`;
@@ -56,13 +54,6 @@ export function globalPreload({port}) {
56
54
  function escover() {
57
55
  const loader = 'escover';
58
56
 
59
- process.on('exit', () => {
60
- port.postMessage({
61
- type: 'exit',
62
- loader: 'escover',
63
- });
64
- });
65
-
66
57
  global.__createC4 = (url) => ({
67
58
  '🧨': (line, column) => {
68
59
  port.postMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "3.5.0",
3
+ "version": "3.5.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",