monocart-coverage-reports 1.0.8 → 1.0.9
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 +1 -0
- package/lib/generate.js +12 -4
- package/lib/index.d.ts +3 -0
- package/lib/utils/util.js +6 -5
- package/lib/v8/v8.js +44 -14
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/generate.js
CHANGED
|
@@ -26,7 +26,7 @@ const generateV8ListReports = async (v8list, coverageData, fileSources, options)
|
|
|
26
26
|
|
|
27
27
|
// generate v8 report
|
|
28
28
|
if (v8) {
|
|
29
|
-
report = await saveV8Report(v8list, options
|
|
29
|
+
report = await saveV8Report(v8list, options);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return report;
|
|
@@ -68,6 +68,7 @@ const getReportGroup = (reports, lcov, dataType) => {
|
|
|
68
68
|
|
|
69
69
|
const allSupportedReports = [
|
|
70
70
|
'v8',
|
|
71
|
+
'v8-json',
|
|
71
72
|
'clover',
|
|
72
73
|
'cobertura',
|
|
73
74
|
'html',
|
|
@@ -86,13 +87,20 @@ const getReportGroup = (reports, lcov, dataType) => {
|
|
|
86
87
|
// group v8 and istanbul
|
|
87
88
|
const reportGroup = {};
|
|
88
89
|
Object.keys(reportMap).forEach((k) => {
|
|
89
|
-
if (k
|
|
90
|
-
reportGroup.v8 = reportMap.v8;
|
|
90
|
+
if (!allSupportedReports.includes(k)) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
if (k.startsWith('v8')) {
|
|
95
|
+
// v8
|
|
96
|
+
if (!reportGroup.v8) {
|
|
97
|
+
reportGroup.v8 = {};
|
|
98
|
+
}
|
|
99
|
+
reportGroup.v8[k] = reportMap[k];
|
|
94
100
|
return;
|
|
95
101
|
}
|
|
102
|
+
|
|
103
|
+
// istanbul
|
|
96
104
|
if (!reportGroup.istanbul) {
|
|
97
105
|
reportGroup.istanbul = {};
|
|
98
106
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/utils/util.js
CHANGED
|
@@ -104,11 +104,6 @@ const Util = {
|
|
|
104
104
|
},
|
|
105
105
|
|
|
106
106
|
resolveNodeModule: (p) => {
|
|
107
|
-
// same level dep
|
|
108
|
-
const dep = path.resolve(__dirname, '../../../', p);
|
|
109
|
-
if (fs.existsSync(dep)) {
|
|
110
|
-
return dep;
|
|
111
|
-
}
|
|
112
107
|
|
|
113
108
|
// root
|
|
114
109
|
const cwd = path.resolve('node_modules', p);
|
|
@@ -122,6 +117,12 @@ const Util = {
|
|
|
122
117
|
return sub;
|
|
123
118
|
}
|
|
124
119
|
|
|
120
|
+
// same level dep
|
|
121
|
+
const dep = path.resolve(__dirname, '../../../', p);
|
|
122
|
+
if (fs.existsSync(dep)) {
|
|
123
|
+
return dep;
|
|
124
|
+
}
|
|
125
|
+
|
|
125
126
|
Util.logError(`Not found module: ${p}`);
|
|
126
127
|
|
|
127
128
|
return cwd;
|
package/lib/v8/v8.js
CHANGED
|
@@ -167,7 +167,30 @@ const mergeV8Coverage = async (dataList, options) => {
|
|
|
167
167
|
|
|
168
168
|
// ============================================================
|
|
169
169
|
|
|
170
|
-
const
|
|
170
|
+
const saveV8JsonReport = async (reportData, options, v8JsonOptions) => {
|
|
171
|
+
const v8MergedOptions = {
|
|
172
|
+
outputFile: 'coverage-report.json',
|
|
173
|
+
... v8JsonOptions
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// console.log(v8MergedOptions);
|
|
177
|
+
const jsonPath = path.resolve(options.outputDir, v8MergedOptions.outputFile);
|
|
178
|
+
// console.log(reportPath);
|
|
179
|
+
await Util.writeFile(jsonPath, JSON.stringify(reportData));
|
|
180
|
+
|
|
181
|
+
return Util.relativePath(jsonPath);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const saveV8HtmlReport = async (reportData, options, v8HtmlOptions) => {
|
|
186
|
+
|
|
187
|
+
// V8 only options, merged with root options
|
|
188
|
+
const v8MergedOptions = {
|
|
189
|
+
outputFile: options.outputFile,
|
|
190
|
+
inline: options.inline,
|
|
191
|
+
assetsPath: options.assetsPath,
|
|
192
|
+
... v8HtmlOptions
|
|
193
|
+
};
|
|
171
194
|
|
|
172
195
|
const {
|
|
173
196
|
outputFile, inline, assetsPath
|
|
@@ -204,8 +227,7 @@ const saveV8HtmlReport = async (reportData, options, v8MergedOptions) => {
|
|
|
204
227
|
return htmlPath;
|
|
205
228
|
};
|
|
206
229
|
|
|
207
|
-
|
|
208
|
-
const saveV8Report = async (v8list, options, v8Options) => {
|
|
230
|
+
const saveV8Report = async (v8list, options) => {
|
|
209
231
|
const defaultWatermarks = {
|
|
210
232
|
bytes: [50, 80]
|
|
211
233
|
};
|
|
@@ -245,24 +267,32 @@ const saveV8Report = async (v8list, options, v8Options) => {
|
|
|
245
267
|
status
|
|
246
268
|
};
|
|
247
269
|
|
|
248
|
-
|
|
249
|
-
const v8MergedOptions = {
|
|
250
|
-
outputFile: options.outputFile,
|
|
251
|
-
inline: options.inline,
|
|
252
|
-
assetsPath: options.assetsPath,
|
|
253
|
-
... v8Options
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const htmlOptions = {
|
|
270
|
+
const reportData = {
|
|
257
271
|
name: options.name,
|
|
258
272
|
watermarks,
|
|
259
273
|
summary,
|
|
260
274
|
files: v8list
|
|
261
275
|
};
|
|
262
276
|
|
|
263
|
-
|
|
277
|
+
let outputPath;
|
|
278
|
+
|
|
279
|
+
// v8 reports
|
|
280
|
+
const v8Map = options.reportGroup.v8;
|
|
281
|
+
|
|
282
|
+
// v8 json
|
|
283
|
+
const v8JsonOptions = v8Map['v8-json'];
|
|
284
|
+
if (v8JsonOptions) {
|
|
285
|
+
outputPath = await saveV8JsonReport(reportData, options, v8JsonOptions);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// v8 html
|
|
289
|
+
const v8HtmlOptions = v8Map.v8;
|
|
290
|
+
if (v8HtmlOptions) {
|
|
291
|
+
outputPath = await saveV8HtmlReport(reportData, options, v8HtmlOptions);
|
|
292
|
+
}
|
|
293
|
+
|
|
264
294
|
const reportPath = Util.resolveReportPath(options, () => {
|
|
265
|
-
return
|
|
295
|
+
return outputPath;
|
|
266
296
|
});
|
|
267
297
|
|
|
268
298
|
const report = {
|