mirror of
https://github.com/BillyOutlast/drop.git
synced 2026-02-04 08:41:17 +01: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;
|
|
}
|