Skip to content

Commit

Permalink
fix: Avoid source-map module during signal-exit handler (#1191)
Browse files Browse the repository at this point in the history
Prior to this change child processes would call upon the source-map
module to remap coverage during the `signal-exit` handler.  This was a
blocker for updating `source-map` to 0.7.x which uses an async
constructor method.

Now we simply save the source-map with the raw coverage data for each
file.  This allows the main nyc process to perform source-map remapping.
The benefit is that the main nyc process can use async code.
  • Loading branch information
coreyfarrell authored Oct 6, 2019
1 parent 22a5ea0 commit 83eb629
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class NYC {
}
}, this)
} else {
coverage = this.sourceMaps.remapCoverage(coverage)
this.sourceMaps.addSourceMaps(coverage)
}

var id = this.processInfo.uuid
Expand Down
4 changes: 4 additions & 0 deletions lib/source-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class SourceMaps {
return sourceMap
}

addSourceMaps (coverage) {
this._sourceMapCache.addInputSourceMapsSync(coverage)
}

remapCoverage (obj) {
const transformed = this._sourceMapCache.transformCoverage(
libCoverage.createCoverageMap(obj)
Expand Down

0 comments on commit 83eb629

Please sign in to comment.