mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 12:32:09 +10:00
21 lines
551 B
TypeScript
21 lines
551 B
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
|
|
export function recursivelyReaddir(dir: string) {
|
|
const result: Array<string> = [];
|
|
const files = fs.readdirSync(dir);
|
|
for (const file of files) {
|
|
const targetDir = path.join(dir, file);
|
|
const stat = fs.lstatSync(targetDir);
|
|
if (stat.isDirectory()) {
|
|
const subdirs = recursivelyReaddir(targetDir);
|
|
const subdirsWithBase = subdirs.map((e) => path.join(dir, e));
|
|
result.push(...subdirsWithBase);
|
|
continue;
|
|
}
|
|
result.push(targetDir);
|
|
}
|
|
|
|
return result;
|
|
}
|