From 9c95e2d21d444ce1d9494584d2ffd6a7fc91d5ac Mon Sep 17 00:00:00 2001 From: nickolay Date: Mon, 23 Mar 2020 13:31:03 +0300 Subject: [PATCH] fix: Merge reports with concurrency limit instead of fetching everything in memory (#1263) --- index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6d74d0831..8bb560c9d 100755 --- a/index.js +++ b/index.js @@ -408,11 +408,16 @@ class NYC { async getCoverageMapFromAllCoverageFiles (baseDirectory) { const map = libCoverage.createCoverageMap({}) + const files = await this.coverageFiles(baseDirectory) - const data = await this.coverageData(baseDirectory) - data.forEach(report => { - map.merge(report) - }) + await pMap( + files, + async f => { + const report = await this.coverageFileLoad(f, baseDirectory) + map.merge(report) + }, + { concurrency: os.cpus().length } + ) map.data = await this.sourceMaps.remapCoverage(map.data)