UNPKG

@nurun-sf/spark-component

Version:

A tool for building spark components

43 lines (35 loc) 1.04 kB
'use strict'; var fs = require('fs'); module.exports = function (cb) { // Read in the summary file. fs.readFile('./coverage/coverage-summary.json', 'utf-8', function (err, data) { data = JSON.parse(data); var summary = { lines: { total: data.total.lines.total, covered: data.total.lines.covered }, statements: { total: data.total.statements.total, covered: data.total.statements.covered }, functions: { total: data.total.functions.total, covered: data.total.functions.covered }, branches: { total: data.total.branches.total, covered: data.total.branches.covered } }; // Distill everything to a single number (to 1 decimal). summary.coverage = Math.round(summary.statements.covered / summary.statements.total * 1000) / 10; // Write out to a file. fs.writeFile('./coverage.json', JSON.stringify(summary), function (err) { if (err) { throw err; } cb(); }); }); };