From 136268ef162f10c5f0d76128ed2db44babd019aa Mon Sep 17 00:00:00 2001 From: cenfun Date: Fri, 8 Dec 2023 12:06:55 +0800 Subject: [PATCH] add types for v8 and fix reportPath allow empty --- lib/index.d.ts | 8 +++++--- lib/utils/util.js | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 486e3fcd..1e541241 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -20,7 +20,11 @@ export type Watermarks = [number, number] | { } export type ReportDescription = - ['v8'] | + ['v8'] | ["v8", { + outputFile?: string, + inline?: boolean, + assetsPath?: string + }] | ['clover'] | ['clover', { file?: string }] | @@ -92,10 +96,8 @@ export type CoverageReportOptions = { // [V8 only](String) Output [sub dir/]filename. Defaults to "index.html" outputFile?: string, - // [V8 only](Boolean) Inline all scripts to the single HTML file. Defaults to false. inline?: boolean, - // [V8 only](String) Assets path if not inline. Defaults to "./assets" assetsPath?: string diff --git a/lib/utils/util.js b/lib/utils/util.js index 52e909d5..4bd0cbb5 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -91,9 +91,13 @@ const Util = { reportPath = reportPath(); } - if (reportPath && typeof reportPath === 'string') { - const p = path.resolve(options.outputDir, reportPath); - return Util.relativePath(p); + if (typeof reportPath === 'string') { + if (reportPath) { + const p = path.resolve(options.outputDir, reportPath); + return Util.relativePath(p); + } + // empty + return reportPath; } // using default html path as report path return htmlPathHandler();