From 83eb6294f9492bf98405ee9fdf6281c3bc199a3d Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Sun, 6 Oct 2019 11:28:17 -0400 Subject: [PATCH] fix: Avoid `source-map` module during `signal-exit` handler (#1191) 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. --- index.js | 2 +- lib/source-maps.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7d121178f..36bd06cfc 100755 --- a/index.js +++ b/index.js @@ -369,7 +369,7 @@ class NYC { } }, this) } else { - coverage = this.sourceMaps.remapCoverage(coverage) + this.sourceMaps.addSourceMaps(coverage) } var id = this.processInfo.uuid diff --git a/lib/source-maps.js b/lib/source-maps.js index d62072548..e77981c95 100644 --- a/lib/source-maps.js +++ b/lib/source-maps.js @@ -37,6 +37,10 @@ class SourceMaps { return sourceMap } + addSourceMaps (coverage) { + this._sourceMapCache.addInputSourceMapsSync(coverage) + } + remapCoverage (obj) { const transformed = this._sourceMapCache.transformCoverage( libCoverage.createCoverageMap(obj)