diff options
Diffstat (limited to 'node_modules/istanbul-lib-instrument/dist')
3 files changed, 32 insertions, 7 deletions
diff --git a/node_modules/istanbul-lib-instrument/dist/instrumenter.js b/node_modules/istanbul-lib-instrument/dist/instrumenter.js index 1307bfd8a..5c4e197c9 100644 --- a/node_modules/istanbul-lib-instrument/dist/instrumenter.js +++ b/node_modules/istanbul-lib-instrument/dist/instrumenter.js @@ -104,12 +104,15 @@ var Instrumenter = function () { * * @param {string} code - the code to instrument * @param {string} filename - the filename against which to track coverage. + * @param {object} [inputSourceMap] - the source map that maps the not instrumented code back to it's original form. + * Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the + * coverage to the untranspiled source. * @returns {string} the instrumented code. */ }, { key: 'instrumentSync', - value: function instrumentSync(code, filename) { + value: function instrumentSync(code, filename, inputSourceMap) { if (typeof code !== 'string') { throw new Error('Code must be a string'); } @@ -120,7 +123,8 @@ var Instrumenter = function () { sourceType: opts.esModules ? "module" : "script" }); var ee = (0, _visitor2.default)(t, filename, { - coverageVariable: opts.coverageVariable + coverageVariable: opts.coverageVariable, + inputSourceMap: inputSourceMap }); var output = {}; var visitor = { @@ -155,17 +159,20 @@ var Instrumenter = function () { * @param {string} code - the code to instrument * @param {string} filename - the filename against which to track coverage. * @param {Function} callback - the callback + * @param {Object} inputSourceMap - the source map that maps the not instrumented code back to it's original form. + * Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the + * coverage to the untranspiled source. */ }, { key: 'instrument', - value: function instrument(code, filename, callback) { + value: function instrument(code, filename, callback, inputSourceMap) { if (!callback && typeof filename === 'function') { callback = filename; filename = null; } try { - var out = this.instrumentSync(code, filename); + var out = this.instrumentSync(code, filename, inputSourceMap); callback(null, out); } catch (ex) { callback(ex); diff --git a/node_modules/istanbul-lib-instrument/dist/source-coverage.js b/node_modules/istanbul-lib-instrument/dist/source-coverage.js index eac98f551..f2fba09fc 100644 --- a/node_modules/istanbul-lib-instrument/dist/source-coverage.js +++ b/node_modules/istanbul-lib-instrument/dist/source-coverage.js @@ -106,6 +106,18 @@ var SourceCoverage = function (_classes$FileCoverage) { counts.push(0); return counts.length - 1; } + + /** + * Assigns an input source map to the coverage that can be used + * to remap the coverage output to the original source + * @param sourceMap {object} the source map + */ + + }, { + key: 'inputSourceMap', + value: function inputSourceMap(sourceMap) { + this.data.inputSourceMap = sourceMap; + } }, { key: 'freeze', value: function freeze() { diff --git a/node_modules/istanbul-lib-instrument/dist/visitor.js b/node_modules/istanbul-lib-instrument/dist/visitor.js index 55a616848..cae5146f5 100644 --- a/node_modules/istanbul-lib-instrument/dist/visitor.js +++ b/node_modules/istanbul-lib-instrument/dist/visitor.js @@ -36,13 +36,17 @@ function genVar(filename) { // and is the `this` for the individual coverage visitors. var VisitState = function () { - function VisitState(types, sourceFilePath) { + function VisitState(types, sourceFilePath, inputSourceMap) { _classCallCheck(this, VisitState); this.varName = genVar(sourceFilePath); this.attrs = {}; this.nextIgnore = null; this.cov = new _sourceCoverage.SourceCoverage(sourceFilePath); + + if (typeof inputSourceMap !== "undefined") { + this.cov.inputSourceMap(inputSourceMap); + } this.types = types; this.sourceMappingURL = null; } @@ -484,13 +488,15 @@ var coverageTemplate = (0, _babelTemplate2.default)('\n var COVERAGE_VAR = (f * @param {string} sourceFilePath - the path to source file * @param {Object} opts - additional options * @param {string} [opts.coverageVariable=__coverage__] the global coverage variable name. + * @param {object} [opts.inputSourceMap=undefined] the input source map, that maps the uninstrumented code back to the + * original code. */ function programVisitor(types) { var sourceFilePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknown.js'; - var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { coverageVariable: '__coverage__' }; + var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { coverageVariable: '__coverage__', inputSourceMap: undefined }; var T = types; - var visitState = new VisitState(types, sourceFilePath); + var visitState = new VisitState(types, sourceFilePath, opts.inputSourceMap); return { enter: function enter(path) { path.traverse(codeVisitor, visitState); |
