This commit is contained in:
Domen Kožar 2019-11-19 17:50:30 +01:00
parent cd5893b2c6
commit 70742d22d9
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
6774 changed files with 1602535 additions and 1 deletions

194
node_modules/istanbul-lib-source-maps/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,194 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.0.6](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.5...istanbul-lib-source-maps@3.0.6) (2019-04-24)
### Bug Fixes
* if LEAST_UPPER_BOUND returns null, try GREATEST_LOWER_BOUND ([#375](https://github.com/istanbuljs/istanbuljs/issues/375)) ([72b0f05](https://github.com/istanbuljs/istanbuljs/commit/72b0f05))
## [3.0.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.4...istanbul-lib-source-maps@3.0.5) (2019-04-09)
**Note:** Version bump only for package istanbul-lib-source-maps
## [3.0.4](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.3...istanbul-lib-source-maps@3.0.4) (2019-04-03)
**Note:** Version bump only for package istanbul-lib-source-maps
## [3.0.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.2...istanbul-lib-source-maps@3.0.3) (2019-03-12)
### Bug Fixes
* Map unique files once, regardless of path separator ([#287](https://github.com/istanbuljs/istanbuljs/issues/287)) ([39a1e56](https://github.com/istanbuljs/istanbuljs/commit/39a1e56))
## [3.0.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.1...istanbul-lib-source-maps@3.0.2) (2019-01-26)
**Note:** Version bump only for package istanbul-lib-source-maps
<a name="3.0.1"></a>
## [3.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@3.0.0...istanbul-lib-source-maps@3.0.1) (2018-12-25)
### Bug Fixes
* correct variable name in source-map transform ([#257](https://github.com/istanbuljs/istanbuljs/issues/257)) ([de9c921](https://github.com/istanbuljs/istanbuljs/commit/de9c921))
<a name="3.0.0"></a>
# [3.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@2.0.1...istanbul-lib-source-maps@3.0.0) (2018-12-19)
### Bug Fixes
* correctly calculate end position of sourcemap statement ([f97ffc7](https://github.com/istanbuljs/istanbuljs/commit/f97ffc7))
### BREAKING CHANGES
* coverage output can now contain Infinity, when a range extends past the source in a file.
<a name="2.0.1"></a>
## [2.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@2.0.0...istanbul-lib-source-maps@2.0.1) (2018-07-07)
**Note:** Version bump only for package istanbul-lib-source-maps
<a name="2.0.0"></a>
# [2.0.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.5...istanbul-lib-source-maps@2.0.0) (2018-06-06)
### Bug Fixes
* use null prototype for map objects ([#177](https://github.com/istanbuljs/istanbuljs/issues/177)) ([9a5a30c](https://github.com/istanbuljs/istanbuljs/commit/9a5a30c))
### BREAKING CHANGES
* a null prototype is now used in several places rather than the default `{}` assignment.
<a name="1.2.5"></a>
## [1.2.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.4...istanbul-lib-source-maps@1.2.5) (2018-05-31)
### Bug Fixes
* process.cwd is a function not a string ([#163](https://github.com/istanbuljs/istanbuljs/issues/163)). ([#171](https://github.com/istanbuljs/istanbuljs/issues/171)) ([9c7802c](https://github.com/istanbuljs/istanbuljs/commit/9c7802c))
<a name="1.2.4"></a>
## [1.2.4](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.3...istanbul-lib-source-maps@1.2.4) (2018-03-04)
**Note:** Version bump only for package istanbul-lib-source-maps
<a name="1.2.3"></a>
## [1.2.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.2...istanbul-lib-source-maps@1.2.3) (2018-02-13)
**Note:** Version bump only for package istanbul-lib-source-maps
<a name="1.2.2"></a>
## [1.2.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.1...istanbul-lib-source-maps@1.2.2) (2017-10-21)
**Note:** Version bump only for package istanbul-lib-source-maps
<a name="1.2.1"></a>
## [1.2.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@1.2.0...istanbul-lib-source-maps@1.2.1) (2017-05-27)
<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))

24
node_modules/istanbul-lib-source-maps/LICENSE generated vendored Normal file
View file

@ -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.

11
node_modules/istanbul-lib-source-maps/README.md generated vendored Normal file
View file

@ -0,0 +1,11 @@
# 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.

15
node_modules/istanbul-lib-source-maps/index.js generated vendored Normal file
View file

@ -0,0 +1,15 @@
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const { MapStore } = require('./lib/map-store');
/**
* @module Exports
*/
module.exports = {
createSourceMapStore(opts) {
return new MapStore(opts);
}
};

View file

@ -0,0 +1,182 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const pathutils = require('./pathutils');
const {
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND
} = require('source-map').SourceMapConsumer;
/**
* AST ranges are inclusive for start positions and exclusive for end positions.
* Source maps are also logically ranges over text, though interacting with
* them is generally achieved by working with explicit positions.
*
* When finding the _end_ location of an AST item, the range behavior is
* important because what we're asking for is the _end_ of whatever range
* corresponds to the end location we seek.
*
* This boils down to the following steps, conceptually, though the source-map
* library doesn't expose primitives to do this nicely:
*
* 1. Find the range on the generated file that ends at, or exclusively
* contains the end position of the AST node.
* 2. Find the range on the original file that corresponds to
* that generated range.
* 3. Find the _end_ location of that original range.
*/
function originalEndPositionFor(sourceMap, generatedEnd) {
// Given the generated location, find the original location of the mapping
// that corresponds to a range on the generated file that overlaps the
// generated file end location. Note however that this position on its
// own is not useful because it is the position of the _start_ of the range
// on the original file, and we want the _end_ of the range.
const beforeEndMapping = originalPositionTryBoth(
sourceMap,
generatedEnd.line,
generatedEnd.column - 1
);
if (beforeEndMapping.source === null) {
return null;
}
// Convert that original position back to a generated one, with a bump
// to the right, and a rightward bias. Since 'generatedPositionFor' searches
// for mappings in the original-order sorted list, this will find the
// mapping that corresponds to the one immediately after the
// beforeEndMapping mapping.
const afterEndMapping = sourceMap.generatedPositionFor({
source: beforeEndMapping.source,
line: beforeEndMapping.line,
column: beforeEndMapping.column + 1,
bias: LEAST_UPPER_BOUND
});
if (
// If this is null, it means that we've hit the end of the file,
// so we can use Infinity as the end column.
afterEndMapping.line === null ||
// If these don't match, it means that the call to
// 'generatedPositionFor' didn't find any other original mappings on
// the line we gave, so consider the binding to extend to infinity.
sourceMap.originalPositionFor(afterEndMapping).line !==
beforeEndMapping.line
) {
return {
source: beforeEndMapping.source,
line: beforeEndMapping.line,
column: Infinity
};
}
// Convert the end mapping into the real original position.
return sourceMap.originalPositionFor(afterEndMapping);
}
/**
* Attempts to determine the original source position, first
* returning the closest element to the left (GREATEST_LOWER_BOUND),
* and next returning the closest element to the right (LEAST_UPPER_BOUND).
*/
function originalPositionTryBoth(sourceMap, line, column) {
const mapping = sourceMap.originalPositionFor({
line,
column,
bias: GREATEST_LOWER_BOUND
});
if (mapping.source === null) {
return sourceMap.originalPositionFor({
line,
column,
bias: LEAST_UPPER_BOUND
});
} else {
return mapping;
}
}
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} generatedLocation the original location Object
* @returns {Object} the remapped location Object
*/
function getMapping(sourceMap, generatedLocation, origFile) {
if (!generatedLocation) {
return null;
}
if (
isInvalidPosition(generatedLocation.start) ||
isInvalidPosition(generatedLocation.end)
) {
return null;
}
const start = originalPositionTryBoth(
sourceMap,
generatedLocation.start.line,
generatedLocation.start.column
);
let end = originalEndPositionFor(sourceMap, generatedLocation.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: generatedLocation.end.line,
column: generatedLocation.end.column,
bias: LEAST_UPPER_BOUND
});
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
}
}
};
}
module.exports = getMapping;

189
node_modules/istanbul-lib-source-maps/lib/map-store.js generated vendored Normal file
View file

@ -0,0 +1,189 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const path = require('path');
const fs = require('fs');
const debug = require('debug')('istanbuljs');
const SMC = require('source-map').SourceMapConsumer;
const pathutils = require('./pathutils');
const sourceStore = require('./source-store');
const transformer = require('./transformer');
/**
* Tracks source maps for registered files
*/
class MapStore {
/**
* @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
*/
constructor(opts = {}) {
this.baseDir = opts.baseDir || null;
this.verbose = opts.verbose || false;
this.sourceStore = sourceStore.create(opts.sourceStore, {
tmpdir: opts.tmpdir
});
this.data = Object.create(null);
}
/**
* 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
*/
registerURL(transformedFilePath, sourceMapUrl) {
const d = 'data:';
if (
sourceMapUrl.length > d.length &&
sourceMapUrl.substring(0, d.length) === d
) {
const b64 = 'base64,';
const 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;
}
const dir = path.dirname(path.resolve(transformedFilePath));
const 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
*/
registerMap(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.
*/
transformCoverage(coverageMap) {
const sourceFinder = filePath => {
const content = this.sourceStore.getSource(filePath);
if (content !== null) {
return content;
}
if (path.isAbsolute(filePath)) {
return fs.readFileSync(filePath, 'utf8');
}
return fs.readFileSync(
pathutils.asAbsolute(filePath, this.baseDir)
);
};
coverageMap.files().forEach(file => {
const coverage = coverageMap.fileCoverageFor(file);
if (coverage.data.inputSourceMap && !this.data[file]) {
this.registerMap(file, coverage.data.inputSourceMap);
}
});
if (Object.keys(this.data).length === 0) {
return {
map: coverageMap,
sourceFinder
};
}
const mappedCoverage = transformer
.create(filePath => {
try {
if (!this.data[filePath]) {
return null;
}
const d = this.data[filePath];
let obj;
if (d.type === 'file') {
obj = JSON.parse(fs.readFileSync(d.data, 'utf8'));
} else if (d.type === 'encoded') {
obj = JSON.parse(
Buffer.from(d.data, 'base64').toString()
);
} else {
obj = d.data;
}
const smc = new SMC(obj);
smc.sources.forEach(s => {
const content = smc.sourceContentFor(s);
if (content) {
const sourceFilePath = pathutils.relativeTo(
s,
filePath
);
this.sourceStore.registerSource(
sourceFilePath,
content
);
}
});
return smc;
} catch (error) {
debug('Error returning source map for ' + filePath);
debug(error.stack);
return null;
}
})
.transform(coverageMap);
return {
map: mappedCoverage,
sourceFinder
};
}
/**
* Disposes temporary resources allocated by this map store
*/
dispose() {
this.sourceStore.dispose();
}
}
module.exports = { MapStore };

113
node_modules/istanbul-lib-source-maps/lib/mapped.js generated vendored Normal file
View file

@ -0,0 +1,113 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const { FileCoverage } = require('istanbul-lib-coverage').classes;
function locString(loc) {
return [
loc.start.line,
loc.start.column,
loc.end.line,
loc.end.column
].join(':');
}
class MappedCoverage extends FileCoverage {
constructor(pathOrObj) {
super(pathOrObj);
this.meta = {
last: {
s: 0,
f: 0,
b: 0
},
seen: {}
};
}
addStatement(loc, hits) {
const key = 's:' + locString(loc);
const { meta } = this;
let 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;
}
addFunction(name, decl, loc, hits) {
const key = 'f:' + locString(decl);
const { meta } = this;
let 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,
decl: this.cloneLocation(decl),
loc: this.cloneLocation(loc)
};
}
this.f[index] = this.f[index] || 0;
this.f[index] += hits;
return index;
}
addBranch(type, loc, branchLocations, hits) {
const key = ['b', ...branchLocations.map(l => locString(l))].join(':');
const { meta } = this;
let index = meta.seen[key];
if (index === undefined) {
index = meta.last.b;
meta.last.b += 1;
meta.seen[key] = index;
this.branchMap[index] = {
loc,
type,
locations: branchLocations.map(l => this.cloneLocation(l))
};
}
if (!this.b[index]) {
this.b[index] = branchLocations.map(() => 0);
}
hits.forEach((hit, i) => {
this.b[index][i] += hit;
});
return index;
}
/* Returns a clone of the location object with only the attributes of interest */
cloneLocation(loc) {
return {
start: {
line: loc.start.line,
column: loc.start.column
},
end: {
line: loc.end.line,
column: loc.end.column
}
};
}
}
module.exports = {
MappedCoverage
};

21
node_modules/istanbul-lib-source-maps/lib/pathutils.js generated vendored Normal file
View file

@ -0,0 +1,21 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const path = require('path');
module.exports = {
isAbsolute: path.isAbsolute,
asAbsolute(file, baseDir) {
return path.isAbsolute(file)
? file
: path.resolve(baseDir || process.cwd(), file);
},
relativeTo(file, origFile) {
return path.isAbsolute(file)
? file
: path.resolve(path.dirname(origFile), file);
}
};

View file

@ -0,0 +1,80 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const mkdirp = require('make-dir');
const rimraf = require('rimraf');
/* This exists for compatibility only to avoid changing the
* prototype chain. */
class SourceStore {}
class MemoryStore extends SourceStore {
constructor() {
super();
this.data = {};
}
registerSource(filePath, sourceText) {
this.data[filePath] = sourceText;
}
getSource(filePath) {
return this.data[filePath] || null;
}
dispose() {}
}
class FileStore extends SourceStore {
constructor(opts = {}) {
super();
const tmpDir = opts.tmpdir || os.tmpdir();
this.counter = 0;
this.mappings = [];
this.basePath = path.resolve(tmpDir, '.istanbul', 'cache_');
mkdirp.sync(path.dirname(this.basePath));
}
registerSource(filePath, sourceText) {
if (this.mappings[filePath]) {
return;
}
this.counter += 1;
const mapFile = this.basePath + this.counter;
this.mappings[filePath] = mapFile;
fs.writeFileSync(mapFile, sourceText, 'utf8');
}
getSource(filePath) {
const mapFile = this.mappings[filePath];
if (!mapFile) {
return null;
}
return fs.readFileSync(mapFile, 'utf8');
}
dispose() {
this.mappings = [];
rimraf.sync(path.dirname(this.basePath));
}
}
module.exports = {
create(type = 'memory', opts = {}) {
if (type.toLowerCase() === 'file') {
return new FileStore(opts);
}
return new MemoryStore(opts);
}
};

View file

@ -0,0 +1,20 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
function getUniqueKey(pathname) {
return pathname.replace(/[\\/]/g, '_');
}
function getOutput(cache) {
return Object.keys(cache).reduce((output, key) => {
const item = cache[key];
return Object.assign(output, {
[item.file]: item.mappedCoverage
});
}, {});
}
module.exports = { getUniqueKey, getOutput };

View file

@ -0,0 +1,134 @@
/*
Copyright 2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const debug = require('debug')('istanbuljs');
const libCoverage = require('istanbul-lib-coverage');
const { MappedCoverage } = require('./mapped');
const getMapping = require('./get-mapping');
const { getUniqueKey, getOutput } = require('./transform-utils');
class SourceMapTransformer {
constructor(finder, opts = {}) {
this.finder = finder;
this.baseDir = opts.baseDir || process.cwd();
}
processFile(fc, sourceMap, coverageMapper) {
let changes = 0;
Object.keys(fc.statementMap).forEach(s => {
const loc = fc.statementMap[s];
const hits = fc.s[s];
const mapping = getMapping(sourceMap, loc, fc.path);
if (mapping) {
changes += 1;
const mappedCoverage = coverageMapper(mapping.source);
mappedCoverage.addStatement(mapping.loc, hits);
}
});
Object.keys(fc.fnMap).forEach(f => {
const fnMeta = fc.fnMap[f];
const hits = fc.f[f];
const mapping = getMapping(sourceMap, fnMeta.decl, fc.path);
const spanMapping = getMapping(sourceMap, fnMeta.loc, fc.path);
if (
mapping &&
spanMapping &&
mapping.source === spanMapping.source
) {
changes += 1;
const mappedCoverage = coverageMapper(mapping.source);
mappedCoverage.addFunction(
fnMeta.name,
mapping.loc,
spanMapping.loc,
hits
);
}
});
Object.keys(fc.branchMap).forEach(b => {
const branchMeta = fc.branchMap[b];
const hits = fc.b[b];
const locs = [];
const mappedHits = [];
let source;
let skip;
branchMeta.locations.forEach((loc, i) => {
const mapping = getMapping(sourceMap, loc, 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;
const mappedCoverage = coverageMapper(source);
mappedCoverage.addBranch(
branchMeta.type,
locs[0] /* XXX */,
locs,
mappedHits
);
}
});
return changes > 0;
}
transform(coverageMap) {
const uniqueFiles = {};
const getMappedCoverage = file => {
const key = getUniqueKey(file);
if (!uniqueFiles[key]) {
uniqueFiles[key] = {
file,
mappedCoverage: new MappedCoverage(file)
};
}
return uniqueFiles[key].mappedCoverage;
};
coverageMap.files().forEach(file => {
const fc = coverageMap.fileCoverageFor(file);
const sourceMap = this.finder(file);
if (!sourceMap) {
uniqueFiles[getUniqueKey(file)] = {
file,
mappedCoverage: fc
};
return;
}
const changed = this.processFile(fc, sourceMap, getMappedCoverage);
if (!changed) {
debug(`File [${file}] ignored, nothing could be mapped`);
}
});
return libCoverage.createCoverageMap(getOutput(uniqueFiles));
}
}
module.exports = {
create(finder, opts) {
return new SourceMapTransformer(finder, opts);
}
};

View file

@ -0,0 +1 @@
../../../rimraf/bin.js

44
node_modules/istanbul-lib-source-maps/package.json generated vendored Normal file
View file

@ -0,0 +1,44 @@
{
"name": "istanbul-lib-source-maps",
"version": "3.0.6",
"description": "Source maps support for istanbul",
"author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",
"main": "index.js",
"files": [
"lib",
"index.js"
],
"scripts": {
"test": "mocha"
},
"dependencies": {
"debug": "^4.1.1",
"istanbul-lib-coverage": "^2.0.5",
"make-dir": "^2.1.0",
"rimraf": "^2.6.3",
"source-map": "^0.6.1"
},
"devDependencies": {
"ts-node": "^8.1.0"
},
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/istanbuljs/istanbuljs/issues"
},
"homepage": "https://istanbul.js.org/",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git"
},
"keywords": [
"istanbul",
"sourcemaps",
"sourcemap",
"source",
"maps"
],
"engines": {
"node": ">=6"
},
"gitHead": "90e60cc47833bb780680f916488ca24f0be36ca2"
}