all files / lib/ index.js

100% Statements 21/21
70% Branches 7/10
100% Functions 4/4
100% Lines 20/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                                                         
'use strict';
 
var _keys = require('babel-runtime/core-js/object/keys');
 
var _keys2 = _interopRequireDefault(_keys);
 
var _assign = require('babel-runtime/core-js/object/assign');
 
var _assign2 = _interopRequireDefault(_assign);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
var fs = require('fs');
var remap = require('./remap');
 
var _require = require('istanbul');
 
var Report = _require.Report;
var Store = _require.Store;
/**
 * The basic API for utilising remap-istanbul
 * @param  {Array} sources The sources that could be consumed and remapped.
 *                                For muliple sources to be combined together, provide
 *                                an array of strings.
 * @param  {Object} reports An object where each key is the report type required and the value
 *                          is report options
 * @param  {Object} remapOptions An object with options for remapping
 *               exclude?  - a string or Regular Expression that filters out
 *                           any coverage where the file path matches
 *               readFile? - a function that can read a file
 *                           syncronously
 *               readJSON? - a function that can read and parse a
 *                           JSON file syncronously
 *               sources?  - a Istanbul store where inline sources will be
 *                           added
 *               warn?     - a function that logs warnings
 */
 
module.exports = function (sources, reports) {
  var remapOptions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
 
  var sourceStore = Store.create('memory');
  var collector = remap(sources.map(function (filePath) {
    return JSON.parse(fs.readFileSync(filePath));
  }), (0, _assign2.default)({}, remapOptions, {
    sources: sourceStore
  }));
 
  (0, _keys2.default)(reports).forEach(function (reportType) {
    var options = (0, _assign2.default)((0, _keys2.default)(sourceStore.map).length ? { sourceStore: sourceStore } : {}, reports[reportType]);
    var reporter = Report.create(reportType, options);
    reporter.writeReport(collector, true);
  });
};
 
module.exports.remap = remap;
//# sourceMappingURL=index.js.map