diff --git a/benchmark/fs/bench-glob.js b/benchmark/fs/bench-glob.js index 74612701e218..4652a48f5241 100644 --- a/benchmark/fs/bench-glob.js +++ b/benchmark/fs/bench-glob.js @@ -16,6 +16,7 @@ const configs = { dir: ['lib'], pattern: ['**/*', '*.js', '**/**.js'], mode: ['sync', 'promise', 'callback'], + maxDepth: ['default', '2'], recursive: ['true', 'false'], }; @@ -23,8 +24,11 @@ const bench = common.createBenchmark(main, configs); async function main(config) { const fullPath = path.resolve(benchmarkDirectory, config.dir); - const { pattern, recursive, mode } = config; + const { pattern, recursive, mode, maxDepth } = config; const options = { cwd: fullPath, recursive }; + if (maxDepth !== 'default') { + options.maxDepth = Number(maxDepth); + } const callback = (resolve, reject) => { glob(pattern, options, (err, matches) => { if (err) { @@ -44,7 +48,10 @@ async function main(config) { noDead = globSync(pattern, options); break; case 'promise': - noDead = await globAsync(pattern, options); + noDead = []; + for await (const match of globAsync(pattern, options)) { + noDead.push(match); + } break; case 'callback': noDead = await new Promise(callback); diff --git a/doc/api/fs.md b/doc/api/fs.md index a38a0151e0a9..a6e2ba7421fc 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1400,6 +1400,9 @@ behavior is similar to `cp dir1/ dir2/`.