Small fixes

This commit is contained in:
Pieter Vander Vennet 2021-05-20 12:27:33 +02:00
parent 092a627b64
commit 95f421a6ae
5 changed files with 17 additions and 9 deletions

View file

@ -4,15 +4,18 @@ import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
export default class ScriptUtils {
public static readDirRecSync(path): string[] {
public static readDirRecSync(path, maxDepth = 999): string[] {
const result = []
if(maxDepth <= 0){
return []
}
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))
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
} else {
result.push(fullEntry)
}