'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 |