mapcomplete/scripts/ScriptUtils.ts
2021-04-10 03:18:32 +02:00

21 lines
588 B
TypeScript

import {lstatSync, readdirSync} from "fs";
export default class ScriptUtils {
public static readDirRecSync(path): string[] {
const result = []
for (const entry of readdirSync(path)) {
const fullEntry = path + "/" + entry
const stats = lstatSync(fullEntry)
if (stats.isDirectory()) {
// Subdirectory
// @ts-ignore
result.push(...ScriptUtils.readDirRecSync(fullEntry))
} else {
result.push(fullEntry)
}
}
return result;
}
}