-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const path = require('path'); | ||
const Util = require('../utils/util.js'); | ||
|
||
const v8JsonReport = async (reportData, reportOptions, options) => { | ||
const v8JsonOptions = { | ||
outputFile: 'coverage-report.json', | ||
... reportOptions | ||
}; | ||
|
||
// console.log(mergedOptions); | ||
const jsonPath = path.resolve(options.outputDir, v8JsonOptions.outputFile); | ||
const reportPath = Util.relativePath(jsonPath); | ||
|
||
reportData.reportPath = reportPath; | ||
|
||
await Util.writeFile(jsonPath, JSON.stringify(reportData)); | ||
return reportPath; | ||
}; | ||
|
||
module.exports = { | ||
v8JsonReport | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const path = require('path'); | ||
const Assets = require('../assets.js'); | ||
|
||
const v8Report = async (reportData, reportOptions, options) => { | ||
|
||
// V8 only options, merged with root options | ||
const v8HtmlOptions = { | ||
outputFile: options.outputFile, | ||
inline: options.inline, | ||
assetsPath: options.assetsPath, | ||
metrics: options.metrics, | ||
... reportOptions | ||
}; | ||
|
||
// add metrics to data for UI | ||
reportData.metrics = v8HtmlOptions.metrics; | ||
|
||
const { | ||
outputFile, inline, assetsPath | ||
} = v8HtmlOptions; | ||
|
||
// resolve full report path | ||
const reportPath = path.resolve(options.outputDir, outputFile); | ||
const outputDir = path.dirname(reportPath); | ||
const htmlFile = path.basename(reportPath); | ||
|
||
const jsFiles = ['monocart-coverage-app']; | ||
// console.log(jsFiles); | ||
|
||
const htmlOptions = { | ||
reportData, | ||
jsFiles, | ||
inline, | ||
assetsPath, | ||
outputDir, | ||
htmlFile, | ||
|
||
saveReportPath: 'reportPath', | ||
|
||
reportDataFile: 'coverage-data.js' | ||
}; | ||
|
||
// compress json data for html | ||
const htmlPath = await Assets.saveHtmlReport(htmlOptions); | ||
|
||
return htmlPath; | ||
}; | ||
|
||
module.exports = { | ||
v8Report | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters