From 0efc6d14a288ac097c9e56ea2bba5c9b2c26acd4 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Mon, 7 Oct 2019 16:13:50 -0400 Subject: [PATCH] chore: Tweak arguments for async coverage data readers (#1198) This allows istanbul-lib-processinfo to read coverage data files using only the `coverageFileLoad` function. --- index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 76d214949..7193ba5cc 100755 --- a/index.js +++ b/index.js @@ -475,15 +475,13 @@ class NYC { }) } - async coverageFiles (baseDirectory) { - const files = await fs.readdir(baseDirectory) - - return files.map(f => path.resolve(baseDirectory, f)) + coverageFiles (baseDirectory = this.tempDirectory()) { + return fs.readdir(baseDirectory) } - async coverageFileLoad (filename) { + async coverageFileLoad (filename, baseDirectory = this.tempDirectory()) { try { - const report = JSON.parse(await fs.readFile(filename), 'utf8') + const report = JSON.parse(await fs.readFile(path.resolve(baseDirectory, filename)), 'utf8') await this.sourceMaps.reloadCachedSourceMaps(report) return report } catch (error) { @@ -491,9 +489,13 @@ class NYC { } } - async coverageData (baseDirectory = this.tempDirectory()) { + async coverageData (baseDirectory) { const files = await this.coverageFiles(baseDirectory) - return pMap(files, f => this.coverageFileLoad(f), { concurrency: os.cpus().length }) + return pMap( + files, + f => this.coverageFileLoad(f, baseDirectory), + { concurrency: os.cpus().length } + ) } /* istanbul ignore next: legacy function used by istanbul-lib-processinfo. */