t-comm
Version:
专业、稳定、纯粹的工具库
14 lines (13 loc) • 554 B
TypeScript
/**
* 同步递归收集目录下所有文件路径
* 递归遍历指定目录,收集所有文件的绝对路径到数组中
* @param {string} dirPath 目录路径
* @param {string[]} [fileList=[]] 用于累积结果的数组(可选,递归内部使用)
* @returns {string[]} 所有文件的绝对路径数组
* @example
* ```ts
* const files = collectFilesSync('/path/to/dir');
* // ['/path/to/dir/a.ts', '/path/to/dir/sub/b.ts', ...]
* ```
*/
export declare function collectFilesSync(dirPath?: string, fileList?: string[]): string[];