Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: logic for handling sourceRoot does not take into account process.cwd() #39

Merged
merged 1 commit into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/v8-to-istanbul.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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