-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial implementation of
minigun report
(#4)
- The command generates a self-contained HTML file with a summary of stats from the JSON file. - HTML is written to minigun_report_xxxxxxx.json.html - Resulting HTML is opened in user's default browser
- Loading branch information
Showing
5 changed files
with
463 additions
and
3 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
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
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,25 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var l = require('lodash'); | ||
var openfile = require('open'); | ||
|
||
module.exports = report; | ||
|
||
function report(jsonReportPath) { | ||
var data = JSON.parse(fs.readFileSync(jsonReportPath, 'utf-8')); | ||
var templateFn = path.join( | ||
path.dirname(__filename), | ||
'../report/index.html.ejs'); | ||
var template = fs.readFileSync(templateFn, 'utf-8'); | ||
var compiledTemplate = l.template(template); | ||
var html = compiledTemplate({report: JSON.stringify(data, null, 2)}); | ||
var reportFilename = jsonReportPath + '.html'; | ||
fs.writeFileSync( | ||
reportFilename, | ||
html, | ||
{encoding: 'utf-8', flag: 'w'}); | ||
console.log('Report generated: %s', reportFilename); | ||
openfile(reportFilename); | ||
} |
Oops, something went wrong.