Skip to content

@longmo-utils/node / getFiles

Function: getFiles()

ts
function getFiles(dirPath, extensions?): Promise<string[]>;

递归获取目录下的所有文件

Parameters

ParameterTypeDescription
dirPathstring目录路径
extensions?string[]可选的文件扩展名过滤器

Returns

Promise<string[]>

文件路径数组

Example

ts
const allFiles = await getFiles('./src')
const tsFiles = await getFiles('./src', ['.ts', '.tsx'])

Released under the MIT License.