Socket
Socket
Sign inDemoInstall

istanbul-lib-source-maps

Package Overview
Dependencies
4
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2

18

CHANGELOG.md

@@ -6,2 +6,20 @@ # Change Log

# [4.0.0-alpha.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.1...istanbul-lib-source-maps@4.0.0-alpha.2) (2019-10-09)
### Features
* Convert to async API ([#489](https://github.com/istanbuljs/istanbuljs/issues/489)) ([f8ebbc9](https://github.com/istanbuljs/istanbuljs/commit/f8ebbc9))
### BREAKING CHANGES
* MapStore#transformCoverage is now async and returns a
the coverage data only. The `sourceFinder` method is now async and
provided directly on the `MapStore` instance.
# [4.0.0-alpha.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-source-maps@4.0.0-alpha.0...istanbul-lib-source-maps@4.0.0-alpha.1) (2019-10-06)

@@ -8,0 +26,0 @@

64

lib/map-store.js

@@ -9,7 +9,10 @@ /*

const fs = require('fs');
const { promisify } = require('util');
const debug = require('debug')('istanbuljs');
const SMC = require('source-map').SourceMapConsumer;
const { SourceMapConsumer } = require('source-map');
const pathutils = require('./pathutils');
const transformer = require('./transformer');
const { SourceMapTransformer } = require('./transformer');
const readFile = promisify(fs.readFile);
/**

@@ -150,2 +153,18 @@ * Tracks source maps for registered files

async sourceFinder(filePath) {
const content = this.sourceStore.get(filePath);
if (content !== undefined) {
return content;
}
if (path.isAbsolute(filePath)) {
return await readFile(filePath, 'utf8');
}
return await readFile(
pathutils.asAbsolute(filePath, this.baseDir),
'utf8'
);
}
/**

@@ -155,22 +174,5 @@ * Transforms the coverage map provided into one that refers to original

* @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.
* @returns {Promise<CoverageMap>} the transformed coverage map
*/
transformCoverage(coverageMap) {
const sourceFinder = filePath => {
const content = this.sourceStore.get(filePath);
if (content !== undefined) {
return content;
}
if (path.isAbsolute(filePath)) {
return fs.readFileSync(filePath, 'utf8');
}
return fs.readFileSync(
pathutils.asAbsolute(filePath, this.baseDir)
);
};
async transformCoverage(coverageMap) {
const hasInputSourceMaps = coverageMap

@@ -183,10 +185,7 @@ .files()

if (!hasInputSourceMaps && Object.keys(this.data).length === 0) {
return {
map: coverageMap,
sourceFinder
};
return coverageMap;
}
const mappedCoverage = transformer
.create((filePath, coverage) => {
const transformer = new SourceMapTransformer(
async (filePath, coverage) => {
try {

@@ -200,3 +199,3 @@ const obj =

const smc = new SMC(obj);
const smc = new SourceMapConsumer(obj);
smc.sources.forEach(s => {

@@ -220,9 +219,6 @@ const content = smc.sourceContentFor(s);

}
})
.transform(coverageMap);
}
);
return {
map: mappedCoverage,
sourceFinder
};
return await transformer.transform(coverageMap);
}

@@ -229,0 +225,0 @@

@@ -92,3 +92,3 @@ /*

transform(coverageMap) {
async transform(coverageMap) {
const uniqueFiles = {};

@@ -107,6 +107,16 @@ const getMappedCoverage = file => {

coverageMap.files().forEach(file => {
for (const file of coverageMap.files()) {
const fc = coverageMap.fileCoverageFor(file);
const sourceMap = this.finder(file, fc);
if (!sourceMap) {
const sourceMap = await this.finder(file, fc);
if (sourceMap) {
const changed = this.processFile(
fc,
sourceMap,
getMappedCoverage
);
if (!changed) {
debug(`File [${file}] ignored, nothing could be mapped`);
}
} else {
uniqueFiles[getUniqueKey(file)] = {

@@ -116,11 +126,5 @@ file,

};
return;
}
}
const changed = this.processFile(fc, sourceMap, getMappedCoverage);
if (!changed) {
debug(`File [${file}] ignored, nothing could be mapped`);
}
});
return libCoverage.createCoverageMap(getOutput(uniqueFiles));

@@ -131,5 +135,3 @@ }

module.exports = {
create(finder, opts) {
return new SourceMapTransformer(finder, opts);
}
SourceMapTransformer
};
{
"name": "istanbul-lib-source-maps",
"version": "4.0.0-alpha.1",
"version": "4.0.0-alpha.2",
"description": "Source maps support for istanbul",

@@ -45,3 +45,3 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

},
"gitHead": "4d5e777a9bc4847d178ad31f379307124cdd1e4f"
"gitHead": "a8b355732367f7c4a740677553b9785f5e9eac61"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc