_default.js 537 B

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