From 242323a2822c7d8f46fc44e7a9b72f95603e4e03 Mon Sep 17 00:00:00 2001 From: Devin McIntyre Date: Mon, 28 Oct 2024 12:14:30 -0600 Subject: [PATCH] feat: #547 add default-summary to report configurations --- index.d.ts | 3 ++- lib/commands/report.js | 3 ++- lib/parse-args.js | 5 +++++ lib/report.js | 10 ++++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 523731bb..edc18131 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,7 +23,8 @@ export declare class Report { src?: Array, allowExternal?: boolean, skipFull?: boolean, - excludeNodeModules?: boolean + excludeNodeModules?: boolean, + defaultSummarizer?: string }) run(): Promise; } diff --git a/lib/commands/report.js b/lib/commands/report.js index ec6e7fcc..b033422c 100644 --- a/lib/commands/report.js +++ b/lib/commands/report.js @@ -37,7 +37,8 @@ exports.outputReport = async function (argv) { skipFull: argv.skipFull, excludeNodeModules: argv.excludeNodeModules, mergeAsync: argv.mergeAsync, - monocartArgv: (argv.experimentalMonocart || process.env.EXPERIMENTAL_MONOCART) ? argv : null + monocartArgv: (argv.experimentalMonocart || process.env.EXPERIMENTAL_MONOCART) ? argv : null, + defaultSummarizer: argv.defaultSummarizer }) await report.run() if (argv.checkCoverage) await checkCoverages(argv, report) diff --git a/lib/parse-args.js b/lib/parse-args.js index 84ff8e3e..a59a083f 100644 --- a/lib/parse-args.js +++ b/lib/parse-args.js @@ -163,6 +163,11 @@ function buildYargs (withCommands = false) { type: 'boolean', describe: 'Use Monocart coverage reports' }) + .option('default-summarizer', { + default: 'pkg', + type: 'string', + describe: 'organization of HTML reports; choice of `pkg`, `nested`, or `flat`' + }) .pkgConf('c8') .demandCommand(1) .check((argv) => { diff --git a/lib/report.js b/lib/report.js index 1fa51dfc..c544c1c3 100644 --- a/lib/report.js +++ b/lib/report.js @@ -37,7 +37,8 @@ class Report { skipFull, excludeNodeModules, mergeAsync, - monocartArgv + monocartArgv, + defaultSummarizer }) { this.reporter = reporter this.reporterOptions = reporterOptions || {} @@ -62,6 +63,7 @@ class Report { this.skipFull = skipFull this.mergeAsync = mergeAsync this.monocartArgv = monocartArgv + this.defaultSummarizer = defaultSummarizer; } _getSrc (src) { @@ -81,7 +83,8 @@ class Report { const context = libReport.createContext({ dir: this.reportsDirectory, watermarks: this.watermarks, - coverageMap: await this.getCoverageMapFromAllCoverageFiles() + coverageMap: await this.getCoverageMapFromAllCoverageFiles(), + defaultSummarizer: this.defaultSummarizer }) for (const _reporter of this.reporter) { @@ -196,8 +199,7 @@ class Report { clean: argv.clean, - // use default value for istanbul - defaultSummarizer: 'pkg', + defaultSummarizer: this.defaultSummarizer, onEnd: (coverageResults) => { // for check coverage