Skip to content

Commit

Permalink
Convert file url to path
Browse files Browse the repository at this point in the history
fix this bug: istanbuljs/nyc#1473
It looks like typescript generated a source map with file urls instead the file paths.

The url module will work in Node >= v10.12.0
https://nodejs.org/api/url.html#urlfileurltopathurl
  • Loading branch information
NikolayMakhonin committed Jun 19, 2022
1 parent c7693d4 commit b0c55ac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/istanbul-lib-source-maps/lib/pathutils.js
Expand Up @@ -5,15 +5,18 @@
'use strict';

const path = require('path');
const url = require('url');

module.exports = {
isAbsolute: path.isAbsolute,
asAbsolute(file, baseDir) {
file = url.fileURLToPath(file)
return path.isAbsolute(file)
? file
: path.resolve(baseDir || process.cwd(), file);
},
relativeTo(file, origFile) {
file = url.fileURLToPath(file)
return path.isAbsolute(file)
? file
: path.resolve(path.dirname(origFile), file);
Expand Down

0 comments on commit b0c55ac

Please sign in to comment.