Skip to content

Commit

Permalink
fix: logic for handling sourceRoot did not take into account process.…
Browse files Browse the repository at this point in the history
…cwd() (#39)
  • Loading branch information
bcoe committed Jun 23, 2019
1 parent e952acc commit 6ed9524
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/v8-to-istanbul.js
@@ -1,4 +1,4 @@
const { relativeTo } = require('./pathutils')
const { isAbsolute, relativeTo } = require('./pathutils')
const assert = require('assert')
const convertSourceMap = require('convert-source-map')
const { dirname, join } = require('path')
Expand Down Expand Up @@ -40,7 +40,9 @@ module.exports = class V8ToIstanbul {
console.warn('v8-to-istanbul: source-mappings from one to many files not yet supported')
this.source = new CovSource(rawSource, this.wrapperLength)
} else {
if (rawSourceMap.sourcemap.sourceRoot) {
if (rawSourceMap.sourcemap.sourceRoot && isAbsolute(rawSourceMap.sourcemap.sourceRoot)) {
// TODO: we should also make source-root work with relative paths, but this needs
// to be combined with the relativeTo logic which takes into account process.cwd().
this.path = join(rawSourceMap.sourcemap.sourceRoot, rawSourceMap.sourcemap.sources[0])
} else {
this.path = relativeTo(rawSourceMap.sourcemap.sources[0], this.path)
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"fix": "standard --fix",
"snapshot": "TAP_SNAPSHOT=1 tap test/*.js",
"test": "c8 --reporter=html --reporter=text tap --no-coverage --no-esm test/*.js",
"posttest": "standard",
Expand Down

0 comments on commit 6ed9524

Please sign in to comment.