Skip to content

Commit

Permalink
feat: bcoe#547 add default-summary to report configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin McIntyre committed Oct 28, 2024
1 parent ff146b4 commit 242323a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export declare class Report {
src?: Array<string>,
allowExternal?: boolean,
skipFull?: boolean,
excludeNodeModules?: boolean
excludeNodeModules?: boolean,
defaultSummarizer?: string
})
run(): Promise<void>;
}
3 changes: 2 additions & 1 deletion lib/commands/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions lib/parse-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 6 additions & 4 deletions lib/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Report {
skipFull,
excludeNodeModules,
mergeAsync,
monocartArgv
monocartArgv,
defaultSummarizer
}) {
this.reporter = reporter
this.reporterOptions = reporterOptions || {}
Expand All @@ -62,6 +63,7 @@ class Report {
this.skipFull = skipFull
this.mergeAsync = mergeAsync
this.monocartArgv = monocartArgv
this.defaultSummarizer = defaultSummarizer;
}

_getSrc (src) {
Expand All @@ -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) {
Expand Down Expand Up @@ -196,8 +199,7 @@ class Report {

clean: argv.clean,

// use default value for istanbul
defaultSummarizer: 'pkg',
defaultSummarizer: this.defaultSummarizer,

onEnd: (coverageResults) => {
// for check coverage
Expand Down

0 comments on commit 242323a

Please sign in to comment.