_default.js 546 B

123456789101112131415161718
  1. const fs = require('fs-extra')
  2. const path = require('path')
  3. module.exports.finalReport = async function(reports, program) {
  4. if (program.reportOutput === undefined) {
  5. return
  6. }
  7. // Ensure the output directory exists.
  8. fs.ensureDirSync(program.reportOutput)
  9. // Write each report to the disk
  10. for(var report of reports) {
  11. var outPath = path.join(program.reportOutput, report.name + '.json')
  12. console.log('saving', outPath)
  13. fs.writeFileSync(outPath, JSON.stringify(report.contents), 'utf8')
  14. }
  15. }