aboutsummaryrefslogtreecommitdiff
path: root/node_modules/istanbul-lib-source-maps
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 00:38:50 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 00:40:43 +0200
commit7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch)
tree6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/istanbul-lib-source-maps
parent963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff)
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/istanbul-lib-source-maps')
-rw-r--r--node_modules/istanbul-lib-source-maps/CHANGELOG.md56
-rw-r--r--node_modules/istanbul-lib-source-maps/LICENSE24
-rw-r--r--node_modules/istanbul-lib-source-maps/README.md12
-rw-r--r--node_modules/istanbul-lib-source-maps/index.js17
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/map-store.js160
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/mapped.js120
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/pathutils.js17
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/source-store.js80
-rw-r--r--node_modules/istanbul-lib-source-maps/lib/transformer.js181
l---------node_modules/istanbul-lib-source-maps/node_modules/.bin/mkdirp1
l---------node_modules/istanbul-lib-source-maps/node_modules/.bin/rimraf1
-rw-r--r--node_modules/istanbul-lib-source-maps/package.json46
12 files changed, 715 insertions, 0 deletions
diff --git a/node_modules/istanbul-lib-source-maps/CHANGELOG.md b/node_modules/istanbul-lib-source-maps/CHANGELOG.md
new file mode 100644
index 000000000..dd847c7b4
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/CHANGELOG.md
@@ -0,0 +1,56 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+<a name="1.2.0"></a>
+# [1.2.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/istanbul-lib-source-maps@1.1.1...istanbul-lib-source-maps@1.2.0) (2017-04-29)
+
+
+### Features
+
+* pull in debug module, to make debug messages optional ([#36](https://github.com/istanbuljs/istanbuljs/issues/36)) ([189519d](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/189519d))
+
+
+
+
+<a name="1.1.1"></a>
+## [1.1.1](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/istanbul-lib-source-maps@1.1.0...istanbul-lib-source-maps@1.1.1) (2017-03-27)
+
+<a name="1.1.0"></a>
+# [1.1.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.2...v1.1.0) (2016-11-10)
+
+
+### Features
+
+* read and apply any input source maps stored with coverage data ([#4](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/4)) ([aea405b](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/aea405b))
+
+
+
+<a name="1.0.2"></a>
+## [1.0.2](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.1...v1.0.2) (2016-10-03)
+
+
+### Bug Fixes
+
+* broken mapped coverage report ([#6](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/6)) ([d9dd738](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/d9dd738))
+
+
+
+<a name="1.0.1"></a>
+## [1.0.1](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.0...v1.0.1) (2016-09-13)
+
+
+### Bug Fixes
+
+* position validation shouldn't throw away locations with 0 ([#5](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/5)) ([ac4b72c](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/ac4b72c))
+
+
+
+<a name="1.0.0"></a>
+# [1.0.0](https://github.com/istanbuljs/istanbul-lib-source-maps/compare/v1.0.0-alpha.9...v1.0.0) (2016-08-31)
+
+
+### Bug Fixes
+
+* discard more bad source map positions ([#3](https://github.com/istanbuljs/istanbul-lib-source-maps/issues/3)) ([ed7b27f](https://github.com/istanbuljs/istanbul-lib-source-maps/commit/ed7b27f))
diff --git a/node_modules/istanbul-lib-source-maps/LICENSE b/node_modules/istanbul-lib-source-maps/LICENSE
new file mode 100644
index 000000000..c05aaafba
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/LICENSE
@@ -0,0 +1,24 @@
+Copyright 2015 Yahoo! Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the Yahoo! Inc. nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/node_modules/istanbul-lib-source-maps/README.md b/node_modules/istanbul-lib-source-maps/README.md
new file mode 100644
index 000000000..05c3538e2
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/README.md
@@ -0,0 +1,12 @@
+istanbul-lib-source-maps
+========================
+
+[![Build Status](https://travis-ci.org/istanbuljs/istanbuljs.svg?branch=master)](https://travis-ci.org/istanbuljs/istanbuljs)
+
+Source map support for istanbuljs.
+
+## Debugging
+
+_istanbul-lib-source-maps_ uses the [debug](https://www.npmjs.com/package/debug) module.
+Run your application with the environment variable `DEBUG=istanbuljs`, to receive debug
+output.
diff --git a/node_modules/istanbul-lib-source-maps/index.js b/node_modules/istanbul-lib-source-maps/index.js
new file mode 100644
index 000000000..225bf5916
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/index.js
@@ -0,0 +1,17 @@
+/*
+ Copyright 2012-2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+"use strict";
+
+var MapStore = require('./lib/map-store').MapStore;
+/**
+ * @module Exports
+ */
+module.exports = {
+ createSourceMapStore: function (opts) {
+ return new MapStore(opts);
+ }
+};
+
+
diff --git a/node_modules/istanbul-lib-source-maps/lib/map-store.js b/node_modules/istanbul-lib-source-maps/lib/map-store.js
new file mode 100644
index 000000000..8b31d4229
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/map-store.js
@@ -0,0 +1,160 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+"use strict";
+
+var debug = require('debug')('istanbuljs'),
+ path = require('path'),
+ fs = require('fs'),
+ pathutils = require('./pathutils'),
+ sourceStore = require('./source-store'),
+ transformer = require('./transformer'),
+ SMC = require('source-map').SourceMapConsumer;
+
+/**
+ * tracks source maps for registered files
+ * @param {Object} opts [opts=undefined] options.
+ * @param {Boolean} opts.verbose [opts.verbose=false] verbose mode
+ * @param {String} opts.baseDir [opts.baseDir=null] alternate base directory
+ * to resolve sourcemap files
+ * @param {String} opts.sourceStore [opts.sourceStore='memory'] - store that tracks
+ * embedded sources found in source maps, one of 'memory' or 'file'
+ * @param {String} opts.tmpdir [opts.tmpdir=undefined] - temporary directory
+ * to use for storing files.
+ * @constructor
+ */
+function MapStore(opts) {
+ opts = opts || {};
+ this.baseDir = opts.baseDir || null;
+ this.verbose = opts.verbose || false;
+ this.sourceStore = sourceStore.create(opts.sourceStore, { tmpdir: opts.tmpdir});
+ this.data = {};
+}
+/**
+ * registers a source map URL with this store. It makes some input sanity checks
+ * and silently fails on malformed input.
+ * @param transformedFilePath - the file path for which the source map is valid.
+ * This must *exactly* match the path stashed for the coverage object to be
+ * useful.
+ * @param sourceMapUrl - the source map URL, **not** a comment
+ */
+MapStore.prototype.registerURL = function (transformedFilePath, sourceMapUrl) {
+ var d = 'data:',
+ b64 = 'base64,',
+ pos;
+
+ if (sourceMapUrl.length > d.length && sourceMapUrl.substring(0, d.length) === d) {
+ pos = sourceMapUrl.indexOf(b64);
+ if (pos > 0) {
+ this.data[transformedFilePath] = {
+ type: 'encoded',
+ data: sourceMapUrl.substring(pos + b64.length)
+ };
+ } else {
+ debug('Unable to interpret source map URL: ' + sourceMapUrl);
+ }
+ return;
+ }
+ var dir = path.dirname(path.resolve(transformedFilePath)),
+ file = path.resolve(dir, sourceMapUrl);
+ this.data[transformedFilePath] = { type: 'file', data: file };
+};
+/**
+ * registers a source map object with this store. Makes some basic sanity checks
+ * and silently fails on malformed input.
+ * @param transformedFilePath - the file path for which the source map is valid
+ * @param sourceMap - the source map object
+ */
+MapStore.prototype.registerMap = function (transformedFilePath, sourceMap) {
+ if (sourceMap && sourceMap.version) {
+ this.data[transformedFilePath] = { type: 'object', data: sourceMap };
+ } else {
+ debug('Invalid source map object:' + JSON.stringify(sourceMap, null, 2));
+ }
+};
+/**
+ * transforms the coverage map provided into one that refers to original
+ * sources when valid mappings have been registered with this store.
+ * @param {CoverageMap} coverageMap - the coverage map to transform
+ * @returns {Object} an object with 2 properties. `map` for the transformed
+ * coverage map and `sourceFinder` which is a function to return the source
+ * text for a file.
+ */
+MapStore.prototype.transformCoverage = function (coverageMap) {
+ var that = this,
+ mappedCoverage,
+ sourceFinder;
+
+ sourceFinder = function (filePath) {
+ var content = that.sourceStore.getSource(filePath);
+ if (content !== null) {
+ return content;
+ }
+ if (pathutils.isAbsolute(filePath)) {
+ return fs.readFileSync(filePath, 'utf8');
+ }
+ return fs.readFileSync(pathutils.asAbsolute(filePath, that.baseDir));
+ };
+
+ coverageMap.files().forEach(function (file) {
+ var coverage = coverageMap.fileCoverageFor(file);
+ if (coverage.data.inputSourceMap && !that.data[file]) {
+ that.registerMap(file, coverage.data.inputSourceMap);
+ }
+ });
+
+ if (Object.keys(this.data).length === 0) {
+ return {
+ map: coverageMap,
+ sourceFinder: sourceFinder
+ };
+ }
+ mappedCoverage = transformer.create(function (filePath) {
+ try {
+ if (!that.data[filePath]) {
+ return null;
+ }
+ var d = that.data[filePath],
+ obj,
+ smc;
+
+ if (d.type === 'file') {
+ obj = JSON.parse(fs.readFileSync(d.data, 'utf8'));
+ } else if (d.type === 'encoded') {
+ obj = JSON.parse(new Buffer(d.data, 'base64').toString());
+ } else {
+ obj = d.data;
+ }
+ smc = new SMC(obj);
+ smc.sources.forEach(function (s) {
+ var content = smc.sourceContentFor(s),
+ sourceFilePath = pathutils.relativeTo(s, filePath);
+ if (content) {
+ that.sourceStore.registerSource(sourceFilePath, content);
+ }
+ });
+ return smc;
+ } catch (ex) {
+ debug('Error returning source map for ' + filePath);
+ debug(ex.stack);
+ return null;
+ }
+ }).transform(coverageMap);
+
+ return {
+ map: mappedCoverage,
+ sourceFinder: sourceFinder
+ };
+};
+
+/**
+ * disposes temporary resources allocated by this map store
+ */
+MapStore.prototype.dispose = function () {
+ this.sourceStore.dispose();
+};
+
+module.exports = {
+ MapStore: MapStore
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/mapped.js b/node_modules/istanbul-lib-source-maps/lib/mapped.js
new file mode 100644
index 000000000..fac8d7d5f
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/mapped.js
@@ -0,0 +1,120 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+"use strict";
+
+var FileCoverage = require('istanbul-lib-coverage').classes.FileCoverage,
+ util = require('util');
+
+function MappedCoverage(pathOrObj) {
+ FileCoverage.call(this, pathOrObj);
+ this.meta = {
+ last: {
+ s: 0,
+ f: 0,
+ b: 0
+ },
+ seen: {}
+ };
+}
+
+util.inherits(MappedCoverage, FileCoverage);
+
+function locString(loc) {
+ return [loc.start.line, loc.start.column, loc.end.line, loc.end.column].join(':');
+}
+
+MappedCoverage.prototype.addStatement = function (loc, hits) {
+ var key = 's:' + locString(loc),
+ meta = this.meta,
+ index = meta.seen[key];
+
+ if (index === undefined) {
+ index = meta.last.s;
+ meta.last.s += 1;
+ meta.seen[key] = index;
+ this.statementMap[index] = this.cloneLocation(loc);
+ }
+ this.s[index] = this.s[index] || 0;
+ this.s[index] += hits;
+ return index;
+};
+
+MappedCoverage.prototype.addFunction = function (name, decl, loc, hits) {
+ var key = 'f:' + locString(decl),
+ meta = this.meta,
+ index = meta.seen[key];
+
+ if (index === undefined) {
+ index = meta.last.f;
+ meta.last.f += 1;
+ meta.seen[key] = index;
+ name = name || '(unknown_' + index + ')';
+ this.fnMap[index] = {
+ name: name,
+ decl: this.cloneLocation(decl),
+ loc: this.cloneLocation(loc)
+ };
+ }
+ this.f[index] = this.f[index] || 0;
+ this.f[index] += hits;
+ return index;
+};
+
+MappedCoverage.prototype.addBranch = function (type, loc, branchLocations, hits) {
+ var key = ['b'],
+ meta = this.meta,
+ that = this,
+ index,
+ i;
+
+ branchLocations.forEach(function (l) {
+ key.push(locString(l));
+ });
+
+ key = key.join(':');
+ index = meta.seen[key];
+ if (index === undefined) {
+ index = meta.last.b;
+ meta.last.b += 1;
+ meta.seen[key] = index;
+ this.branchMap[index] = {
+ loc: loc,
+ type: type,
+ locations: branchLocations.map(function (l) {
+ return that.cloneLocation(l);
+ })
+ };
+ }
+
+ if (!this.b[index]) {
+ this.b[index] = [];
+ branchLocations.forEach(function () {
+ that.b[index].push(0);
+ });
+ }
+ for (i = 0; i < hits.length; i += 1) {
+ that.b[index][i] += hits[i];
+ }
+ return index;
+};
+
+// returns a clone of the location object with only
+// the attributes of interest
+MappedCoverage.prototype.cloneLocation = function (loc) {
+ return {
+ start: {
+ line: loc.start.line,
+ column: loc.start.column
+ },
+ end: {
+ line: loc.end.line,
+ column: loc.end.column
+ }
+ };
+};
+
+module.exports = {
+ MappedCoverage: MappedCoverage
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/pathutils.js b/node_modules/istanbul-lib-source-maps/lib/pathutils.js
new file mode 100644
index 000000000..c72eb6ecf
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/pathutils.js
@@ -0,0 +1,17 @@
+var path = require('path'),
+ isAbsolute = function (p) {
+ if (path.isAbsolute) {
+ return path.isAbsolute(p);
+ }
+ return path.resolve(p) === path.normalize(p);
+ };
+
+exports.isAbsolute = isAbsolute;
+
+exports.asAbsolute = function (file, baseDir) {
+ return isAbsolute(file) ? file : path.resolve(baseDir || process.cwd, file);
+};
+
+exports.relativeTo = function (file, origFile) {
+ return isAbsolute(file) ? file : path.resolve(path.dirname(origFile), file);
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/source-store.js b/node_modules/istanbul-lib-source-maps/lib/source-store.js
new file mode 100644
index 000000000..cb84e9ec8
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/source-store.js
@@ -0,0 +1,80 @@
+var util = require('util'),
+ os = require('os'),
+ path = require('path'),
+ mkdirp = require('mkdirp'),
+ rimraf = require('rimraf'),
+ fs = require('fs');
+
+function SourceStore(/*opts*/) {
+}
+
+SourceStore.prototype.registerSource = function (/* filePath, sourceText */) {
+ throw new Error('registerSource must be overridden');
+};
+
+SourceStore.prototype.getSource = function (/* filePath */) {
+ throw new Error('getSource must be overridden');
+};
+
+SourceStore.prototype.dispose = function () {
+};
+
+function MemoryStore() {
+ this.data = {};
+}
+
+util.inherits(MemoryStore, SourceStore);
+
+MemoryStore.prototype.registerSource = function (filePath, sourceText) {
+ this.data[filePath] = sourceText;
+};
+
+MemoryStore.prototype.getSource = function (filePath) {
+ return this.data[filePath] || null;
+};
+
+function FileStore(opts) {
+ opts = opts || {};
+ var tmpDir = opts.tmpdir || os.tmpdir();
+ this.counter = 0;
+ this.mappings = [];
+ this.basePath = path.resolve(tmpDir, '.istanbul', 'cache_');
+ mkdirp.sync(path.dirname(this.basePath));
+}
+
+util.inherits(FileStore, SourceStore);
+
+FileStore.prototype.registerSource = function (filePath, sourceText) {
+ if (this.mappings[filePath]) {
+ return;
+ }
+ this.counter += 1;
+ var mapFile = this.basePath + this.counter;
+ this.mappings[filePath] = mapFile;
+ fs.writeFileSync(mapFile, sourceText, 'utf8');
+};
+
+FileStore.prototype.getSource = function (filePath) {
+ var mapFile = this.mappings[filePath];
+ if (!mapFile) {
+ return null;
+ }
+ return fs.readFileSync(mapFile, 'utf8');
+};
+
+FileStore.prototype.dispose = function () {
+ this.mappings = [];
+ rimraf.sync(path.dirname(this.basePath));
+};
+
+module.exports = {
+ create: function (type, opts) {
+ opts = opts || {};
+ type = (type || 'memory').toLowerCase();
+
+ if (type === 'file') {
+ return new FileStore(opts);
+ }
+ return new MemoryStore(opts);
+ }
+};
diff --git a/node_modules/istanbul-lib-source-maps/lib/transformer.js b/node_modules/istanbul-lib-source-maps/lib/transformer.js
new file mode 100644
index 000000000..748805949
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/lib/transformer.js
@@ -0,0 +1,181 @@
+/*
+ Copyright 2015, Yahoo Inc.
+ Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
+ */
+"use strict";
+
+var debug = require('debug')('istanbuljs'),
+ pathutils = require('./pathutils'),
+ libCoverage = require('istanbul-lib-coverage'),
+ MappedCoverage = require('./mapped').MappedCoverage;
+
+function isInvalidPosition (pos) {
+ return !pos || typeof pos.line !== "number" || typeof pos.column !== "number" || pos.line < 0 || pos.column < 0;
+}
+
+/**
+ * determines the original position for a given location
+ * @param {SourceMapConsumer} sourceMap the source map
+ * @param {Object} location the original location Object
+ * @returns {Object} the remapped location Object
+ */
+function getMapping(sourceMap, location, origFile) {
+
+ if (!location) {
+ return null;
+ }
+
+ if (isInvalidPosition(location.start) || isInvalidPosition(location.end)) {
+ return null;
+ }
+
+ var start = sourceMap.originalPositionFor(location.start),
+ end = sourceMap.originalPositionFor(location.end);
+
+ /* istanbul ignore if: edge case too hard to test for */
+ if (!(start && end)) {
+ return null;
+ }
+ if (!(start.source && end.source)) {
+ return null;
+ }
+ if (start.source !== end.source) {
+ return null;
+ }
+
+ /* istanbul ignore if: edge case too hard to test for */
+ if (start.line === null || start.column === null) {
+ return null;
+ }
+ /* istanbul ignore if: edge case too hard to test for */
+ if (end.line === null || end.column === null) {
+ return null;
+ }
+
+ if (start.line === end.line && start.column === end.column) {
+ end = sourceMap.originalPositionFor({
+ line: location.end.line,
+ column: location.end.column,
+ bias: 2
+ });
+ end.column = end.column - 1;
+ }
+
+ return {
+ source: pathutils.relativeTo(start.source, origFile),
+ loc: {
+ start: {
+ line: start.line,
+ column: start.column
+ },
+ end: {
+ line: end.line,
+ column: end.column
+ }
+ }
+ };
+}
+
+function SourceMapTransformer(finder, opts) {
+ opts = opts || {};
+ this.finder = finder;
+ this.baseDir = opts.baseDir || process.cwd();
+}
+
+SourceMapTransformer.prototype.processFile = function (fc, sourceMap, coverageMapper) {
+ var changes = 0;
+
+ Object.keys(fc.statementMap).forEach(function (s) {
+ var loc = fc.statementMap[s],
+ hits = fc.s[s],
+ mapping = getMapping(sourceMap, loc, fc.path),
+ mappedCoverage;
+
+ if (mapping) {
+ changes += 1;
+ mappedCoverage = coverageMapper(mapping.source);
+ mappedCoverage.addStatement(mapping.loc, hits);
+ }
+ });
+
+ Object.keys(fc.fnMap).forEach(function (f) {
+ var fnMeta = fc.fnMap[f],
+ hits = fc.f[f],
+ mapping = getMapping(sourceMap, fnMeta.decl, fc.path),
+ spanMapping = getMapping(sourceMap, fnMeta.loc, fc.path),
+ mappedCoverage;
+
+ if (mapping && spanMapping && mapping.source === spanMapping.source) {
+ changes += 1;
+ mappedCoverage = coverageMapper(mapping.source);
+ mappedCoverage.addFunction(fnMeta.name, mapping.loc, spanMapping.loc, hits);
+ }
+ });
+
+ Object.keys(fc.branchMap).forEach(function (b) {
+ var branchMeta = fc.branchMap[b],
+ source,
+ hits = fc.b[b],
+ mapping,
+ locs = [],
+ mappedHits = [],
+ mappedCoverage,
+ skip,
+ i;
+ for (i = 0; i < branchMeta.locations.length; i += 1) {
+ mapping = getMapping(sourceMap, branchMeta.locations[i], fc.path);
+ if (mapping) {
+ if (!source) {
+ source = mapping.source;
+ }
+ if (mapping.source !== source) {
+ skip = true;
+ }
+ locs.push(mapping.loc);
+ mappedHits.push(hits[i]);
+ }
+ }
+ if (!skip && locs.length > 0) {
+ changes += 1;
+ mappedCoverage = coverageMapper(source);
+ mappedCoverage.addBranch(branchMeta.type, locs[0] /* XXX */, locs, mappedHits);
+ }
+ });
+
+ return changes > 0;
+};
+
+SourceMapTransformer.prototype.transform = function (coverageMap) {
+ var that = this,
+ finder = this.finder,
+ output = {},
+ getMappedCoverage = function (file) {
+ if (!output[file]) {
+ output[file] = new MappedCoverage(file);
+ }
+ return output[file];
+ };
+
+ coverageMap.files().forEach(function (file) {
+ var fc = coverageMap.fileCoverageFor(file),
+ sourceMap = finder(file),
+ changed;
+
+ if (!sourceMap) {
+ output[file] = fc;
+ return;
+ }
+
+ changed = that.processFile(fc, sourceMap, getMappedCoverage);
+ if (!changed) {
+ debug('File [' + file + '] ignored, nothing could be mapped');
+ }
+ });
+ return libCoverage.createCoverageMap(output);
+};
+
+module.exports = {
+ create: function (finder, opts) {
+ return new SourceMapTransformer(finder, opts);
+ }
+};
diff --git a/node_modules/istanbul-lib-source-maps/node_modules/.bin/mkdirp b/node_modules/istanbul-lib-source-maps/node_modules/.bin/mkdirp
new file mode 120000
index 000000000..91a5f623f
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/node_modules/.bin/mkdirp
@@ -0,0 +1 @@
+../../../mkdirp/bin/cmd.js \ No newline at end of file
diff --git a/node_modules/istanbul-lib-source-maps/node_modules/.bin/rimraf b/node_modules/istanbul-lib-source-maps/node_modules/.bin/rimraf
new file mode 120000
index 000000000..632d6da23
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/node_modules/.bin/rimraf
@@ -0,0 +1 @@
+../../../rimraf/bin.js \ No newline at end of file
diff --git a/node_modules/istanbul-lib-source-maps/package.json b/node_modules/istanbul-lib-source-maps/package.json
new file mode 100644
index 000000000..51b06488d
--- /dev/null
+++ b/node_modules/istanbul-lib-source-maps/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "istanbul-lib-source-maps",
+ "version": "1.2.0",
+ "description": "Source maps support for istanbul",
+ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",
+ "main": "index.js",
+ "files": [
+ "lib",
+ "index.js"
+ ],
+ "scripts": {
+ "pretest": "jshint index.js lib/ test/",
+ "test": "mocha"
+ },
+ "dependencies": {
+ "debug": "^2.6.3",
+ "istanbul-lib-coverage": "^1.1.0",
+ "mkdirp": "^0.5.1",
+ "rimraf": "^2.6.1",
+ "source-map": "^0.5.3"
+ },
+ "devDependencies": {
+ "babel-core": "^6.2.1",
+ "chai": "^3.4.1",
+ "is-windows": "^1.0.0",
+ "jshint": "^2.8.0",
+ "mocha": "^3.2.0",
+ "ts-node": "^2.0.0"
+ },
+ "license": "BSD-3-Clause",
+ "bugs": {
+ "url": "https://github.com/istanbuljs/istanbul-lib-source-maps/issues"
+ },
+ "homepage": "https://github.com/istanbuljs/istanbul-lib-source-maps#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/istanbuljs/istanbul-lib-source-maps.git"
+ },
+ "keywords": [
+ "istanbul",
+ "sourcemaps",
+ "sourcemap",
+ "source",
+ "maps"
+ ]
+}