Skip to content

Commit 51849d0

Browse files
Merge pull request #249 from RA80533/refactor/async-io
Optimize glob functionality
2 parents cbb3689 + 640697d commit 51849d0

File tree

5 files changed

+35
-76
lines changed

5 files changed

+35
-76
lines changed

npm-shrinkwrap.json

Lines changed: 20 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"homepage": "https://github.com/codecov/uploader#readme",
2929
"dependencies": {
30+
"fast-glob": "^3.2.7",
3031
"glob": "7.1.7",
3132
"js-yaml": "4.1.0",
3233
"line-reader": "0.4.0",

src/helpers/files.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const childProcess = require('child_process')
2+
const glob = require('fast-glob')
23
const fs = require('fs')
3-
const glob = require('glob')
44
const path = require('path').posix
55
const { logAndThrow } = require('./util')
66
const { error, info, verbose } = require('./logger')
@@ -159,17 +159,15 @@ function coverageFilePatterns() {
159159
*
160160
* @param {string} projectRoot
161161
* @param {string[]} coverageFilePatterns
162-
* @returns {string[]}
162+
* @returns {Promise<string[]>}
163163
*/
164-
function getCoverageFiles(projectRoot, coverageFilePatterns) {
165-
return coverageFilePatterns.flatMap(
166-
/** @type {string} */ pattern => {
167-
return glob.sync(`**/${pattern}`, {
168-
cwd: projectRoot,
169-
ignore: globBlacklist(),
170-
})
171-
},
172-
)
164+
async function getCoverageFiles(projectRoot, coverageFilePatterns) {
165+
const globstar = (/** @type {string} */ pattern) => `**/${pattern}`
166+
167+
return glob(coverageFilePatterns.map(globstar), {
168+
cwd: projectRoot,
169+
ignore: globBlacklist(),
170+
})
173171
}
174172

175173
/**

0 commit comments

Comments
 (0)