monocart-coverage-reports 2.6.1 → 2.6.2

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/README.md CHANGED
@@ -258,15 +258,15 @@ const coverageOptions = {
258
258
 
259
259
  ## `mcr` CLI
260
260
  > The CLI will run the program as a [child process](https://nodejs.org/docs/latest/api/child_process.html) with `NODE_V8_COVERAGE=dir` until it exits gracefully, and generate the coverage report with the coverage data from the `dir`.
261
- - Global mode
261
+ - Installing globally
262
262
  ```sh
263
263
  npm i monocart-coverage-reports -g
264
- mcr "node ./test/test-node-env.js" -r v8,console-summary --lcov
264
+ mcr node ./test/test-node-env.js -r v8,console-summary --lcov
265
265
  ```
266
- - Current working directory mode
266
+ - Locally in your project
267
267
  ```sh
268
268
  npm i monocart-coverage-reports
269
- npx mcr "node ./test/test-node-env.js" -r v8,console-summary --lcov
269
+ npx mcr node ./test/test-node-env.js -r v8,console-summary --lcov
270
270
  ```
271
271
  - CLI Options
272
272
  ```sh
@@ -293,15 +293,15 @@ Options:
293
293
  --logging <logging> off, error, info, debug
294
294
  -h, --help display help for command
295
295
  ```
296
- - Supports loading default configuration file
296
+ - Loading default configuration file
297
297
  - `.mcrrc`
298
298
  - `mcr.config.json`
299
299
  - `mcr.config.mjs`
300
300
  - `mcr.config.cjs`
301
301
  - `mcr.config.js`
302
- - Specify custom configuration file
302
+ - Or loading custom configuration file with `-c` or `--config`
303
303
  ```sh
304
- mcr "node ./test.js" -c path-to/my-custom-config.js
304
+ mcr node ./test.js -c path-to/my-custom-config.js
305
305
  ```
306
306
 
307
307
  ## Compare Reports
package/lib/cli.js CHANGED
@@ -227,6 +227,7 @@ program
227
227
  .description('CLI to generate coverage reports')
228
228
  .version(version)
229
229
  .argument('<command>', 'command to execute')
230
+ .allowUnknownOption()
230
231
  .option('-c, --config <path>', 'custom config path')
231
232
  .option('-o, --outputDir <dir>', 'output dir for reports')
232
233
  .option('-r, --reports <name[,name]>', 'coverage reports to use')
@@ -244,7 +245,8 @@ program
244
245
 
245
246
  .option('--logging <logging>', 'off, error, info, debug')
246
247
 
247
- .action((command, cliOptions) => {
248
+ .action((_command, cliOptions) => {
249
+ const command = program.args.join(' ');
248
250
  executeCommand(command, cliOptions);
249
251
  });
250
252
 
package/lib/generate.js CHANGED
@@ -21,21 +21,22 @@ const { getGroupedRows } = require('./utils/snapshot.js');
21
21
  // maybe v8 or to istanbul reports
22
22
  const generateV8ListReports = async (v8list, coverageData, fileSources, options) => {
23
23
 
24
- let report;
25
-
26
- const { v8, istanbul } = options.reportGroup;
27
-
28
- // generate istanbul reports first
29
- if (istanbul) {
30
- report = await saveIstanbulReports(coverageData, fileSources, options);
24
+ let istanbulCoverageResults;
25
+ // v8 to istanbul reports
26
+ if (options.reportGroup.istanbul) {
27
+ istanbulCoverageResults = await saveIstanbulReports(coverageData, fileSources, options);
31
28
  }
32
29
 
33
- // generate v8 report
34
- if (v8) {
35
- report = await saveV8Report(v8list, options);
30
+ // v8 reports and v8 coverage results
31
+ // could be no v8 or v8-json, but requires v8 coverage results
32
+ const v8CoverageResults = await saveV8Report(v8list, options);
33
+
34
+ // fix reportPath
35
+ if (!v8CoverageResults.reportPath && istanbulCoverageResults) {
36
+ v8CoverageResults.reportPath = istanbulCoverageResults.reportPath;
36
37
  }
37
38
 
38
- return report;
39
+ return v8CoverageResults;
39
40
  };
40
41
 
41
42
  // ========================================================================================================
package/lib/v8/v8.js CHANGED
@@ -356,7 +356,7 @@ const saveV8Report = async (v8list, options) => {
356
356
  files: v8list
357
357
  };
358
358
 
359
- // v8 reports
359
+ // v8 only reports
360
360
  const buildInV8Reports = {
361
361
  'v8': handleV8HtmlReport,
362
362
  'v8-json': handleV8JsonReport
@@ -364,14 +364,17 @@ const saveV8Report = async (v8list, options) => {
364
364
 
365
365
  const outputs = {};
366
366
  const v8Group = options.reportGroup.v8;
367
- const v8Reports = Object.keys(v8Group);
368
- for (const reportName of v8Reports) {
369
- const reportOptions = v8Group[reportName];
370
- const buildInHandler = buildInV8Reports[reportName];
371
- if (buildInHandler) {
372
- outputs[reportName] = await buildInHandler(reportData, reportOptions, options);
373
- } else {
374
- outputs[reportName] = await Util.runCustomReporter(reportName, reportData, reportOptions, options);
367
+ // could be no v8 only reports, but have `both` data reports
368
+ if (v8Group) {
369
+ const v8Reports = Object.keys(v8Group);
370
+ for (const reportName of v8Reports) {
371
+ const reportOptions = v8Group[reportName];
372
+ const buildInHandler = buildInV8Reports[reportName];
373
+ if (buildInHandler) {
374
+ outputs[reportName] = await buildInHandler(reportData, reportOptions, options);
375
+ } else {
376
+ outputs[reportName] = await Util.runCustomReporter(reportName, reportData, reportOptions, options);
377
+ }
375
378
  }
376
379
  }
377
380
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-coverage-reports",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "Monocart coverage reports",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -34,11 +34,11 @@
34
34
  "test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
35
35
  "test-anonymous": "node ./test/test-anonymous.js",
36
36
  "test-css": "node ./test/test-css.js",
37
- "test-cli": "npx mcr \"node ./test/test-node-env.js\" -o docs/cli -c test/cli-options.js",
37
+ "test-cli": "npx mcr node ./test/test-node-env.js -o docs/cli -c test/cli-options.js",
38
38
  "test-merge": "node ./test/test-merge.js",
39
39
  "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
40
40
  "test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
41
- "test": "npx mcr \"npm run test-all\" -c test/mcr-options.js",
41
+ "test": "npx mcr npm run test-all -c test/mcr-options.js",
42
42
  "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
43
43
  "dev": "sf d v8",
44
44
  "open": "node ./scripts/open.js",