Skip to content

Commit

Permalink
fix: sourceFinder cannot be async. (#501)
Browse files Browse the repository at this point in the history
This function needs to be passed to report context constructors.
  • Loading branch information
coreyfarrell committed Nov 16, 2019
1 parent 886e19c commit 094f1b8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/istanbul-lib-source-maps/lib/map-store.js
Expand Up @@ -6,14 +6,11 @@

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

const readFile = promisify(fs.readFile);

/**
* Tracks source maps for registered files
*/
Expand Down Expand Up @@ -41,6 +38,7 @@ class MapStore {
this.verbose = opts.verbose;
this.sourceStore = new opts.SourceStore(...opts.sourceStoreOpts);
this.data = Object.create(null);
this.sourceFinder = this.sourceFinder.bind(this);
}

/**
Expand Down Expand Up @@ -149,17 +147,17 @@ class MapStore {
});
}

async sourceFinder(filePath) {
sourceFinder(filePath) {
const content = this.sourceStore.get(filePath);
if (content !== undefined) {
return content;
}

if (path.isAbsolute(filePath)) {
return await readFile(filePath, 'utf8');
return fs.readFileSync(filePath, 'utf8');
}

return await readFile(
return fs.readFileSync(
pathutils.asAbsolute(filePath, this.baseDir),
'utf8'
);
Expand Down

0 comments on commit 094f1b8

Please sign in to comment.