istanbul-lib-instrument
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/istanbuljs/istanbul-lib-instrument/compare/v1.2.0...v1.3.0) (2016-11-10) | ||
### Features | ||
* allow an input source-map to be passed to instrumentSync() ([#23](https://github.com/istanbuljs/istanbul-lib-instrument/issues/23)) ([b08e4f5](https://github.com/istanbuljs/istanbul-lib-instrument/commit/b08e4f5)) | ||
<a name="1.2.0"></a> | ||
@@ -7,0 +17,0 @@ # [1.2.0](https://github.com/istanbuljs/istanbul-lib-instrument/compare/v1.1.4...v1.2.0) (2016-10-25) |
@@ -107,2 +107,5 @@ 'use strict'; | ||
* @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. | ||
@@ -113,3 +116,3 @@ */ | ||
key: 'instrumentSync', | ||
value: function instrumentSync(code, filename) { | ||
value: function instrumentSync(code, filename, inputSourceMap) { | ||
if (typeof code !== 'string') { | ||
@@ -125,3 +128,4 @@ throw new Error('Code must be a string'); | ||
var ee = (0, _visitor2.default)(t, filename, { | ||
coverageVariable: opts.coverageVariable | ||
coverageVariable: opts.coverageVariable, | ||
inputSourceMap: inputSourceMap | ||
}); | ||
@@ -161,2 +165,5 @@ var output = {}; | ||
* @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. | ||
*/ | ||
@@ -166,3 +173,3 @@ | ||
key: 'instrument', | ||
value: function instrument(code, filename, callback) { | ||
value: function instrument(code, filename, callback, inputSourceMap) { | ||
if (!callback && typeof filename === 'function') { | ||
@@ -173,3 +180,3 @@ callback = filename; | ||
try { | ||
var out = this.instrumentSync(code, filename); | ||
var out = this.instrumentSync(code, filename, inputSourceMap); | ||
callback(null, out); | ||
@@ -176,0 +183,0 @@ } catch (ex) { |
@@ -109,3 +109,15 @@ 'use strict'; | ||
} | ||
/** | ||
* 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', | ||
@@ -112,0 +124,0 @@ value: function freeze() { |
@@ -39,3 +39,3 @@ 'use strict'; | ||
var VisitState = function () { | ||
function VisitState(types, sourceFilePath) { | ||
function VisitState(types, sourceFilePath, inputSourceMap) { | ||
_classCallCheck(this, VisitState); | ||
@@ -47,2 +47,6 @@ | ||
this.cov = new _sourceCoverage.SourceCoverage(sourceFilePath); | ||
if (typeof inputSourceMap !== "undefined") { | ||
this.cov.inputSourceMap(inputSourceMap); | ||
} | ||
this.types = types; | ||
@@ -489,9 +493,11 @@ this.sourceMappingURL = null; | ||
* @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 { | ||
@@ -498,0 +504,0 @@ enter: function enter(path) { |
{ | ||
"name": "istanbul-lib-instrument", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Core istanbul API for JS code coverage", | ||
@@ -5,0 +5,0 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>", |
98080
868