diff --git a/src/utils/path/index.ts b/src/utils/path/index.ts new file mode 100644 index 0000000..1af1246 --- /dev/null +++ b/src/utils/path/index.ts @@ -0,0 +1 @@ +export * from "./path"; \ No newline at end of file diff --git a/src/utils/path/path.ts b/src/utils/path/path.ts new file mode 100644 index 0000000..d8485a5 --- /dev/null +++ b/src/utils/path/path.ts @@ -0,0 +1,19 @@ +import { readdir, stat } from "fs/promises"; +import { sep as separator } from "path"; + +export const getFiles = async(path: string, filter: string[] = [], files: string[] = []): Promise => { + const fileList = await readdir(path); + + for (const file of fileList) { + const name = `${path}${separator}${file}`; + const entityStat = await stat(name); + + if (entityStat.isDirectory()) { + await getFiles(name, filter, files); + } else { + files.push(name); + } + } + + return files; +}; \ No newline at end of file