fsPromises.glob(pattern[, options])
¥Stability: 1 - Experimental
-
pattern<string> | <string[]> -
options<Object>-
cwd<string> 当前工作目录。默认值:process.cwd()¥
cwd<string> current working directory. Default:process.cwd() -
exclude<Function> | <string[]> 用于过滤文件/目录或要排除的 glob 模式列表的函数。如果提供了函数,则返回true以排除该项目,返回false以包含它。默认值:undefined。¥
exclude<Function> | <string[]> Function to filter out files/directories or a list of glob patterns to be excluded. If a function is provided, returntrueto exclude the item,falseto include it. Default:undefined. -
withFileTypes<boolean> 如果 glob 应将路径返回为 Dirents,则为true,否则为false。默认值:false。¥
withFileTypes<boolean>trueif the glob should return paths as Dirents,falseotherwise. Default:false.
-
-
返回:<AsyncIterator> 一个 AsyncIterator,它生成与模式匹配的文件的路径。
¥Returns: <AsyncIterator> An AsyncIterator that yields the paths of files that match the pattern.
import { glob } from 'node:fs/promises';
for await (const entry of glob('**/*.js'))
console.log(entry);const { glob } = require('node:fs/promises');
(async () => {
for await (const entry of glob('**/*.js'))
console.log(entry);
})();