From 7ed05525b5562c8e7c648dec8f19661808128ce6 Mon Sep 17 00:00:00 2001 From: Elihuso Quigley Date: Sat, 25 May 2024 20:14:37 +0800 Subject: [PATCH] [F] fix empty dir crash build --- scripts/build.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/build.ts b/scripts/build.ts index 6aa1c777..bba1ead7 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -53,6 +53,7 @@ function buildPeopleInfoAndList() { for (const { dirname, srcPath, distPath } of people) { if (excludeList.includes(dirname)) continue; + if (isDirEmpty(srcPath)) continue; const infoFile = fs.readFileSync(path.join(srcPath, `info.yml`), "utf-8"); const info: any = YAML.load(infoFile); @@ -132,6 +133,7 @@ function buildPeoplePages() { for (const { dirname, srcPath, distPath } of people) { if (excludeList.includes(dirname)) continue; + if (isDirEmpty(srcPath)) continue; for (const lang of ['', '.zh_hant', '.en']) { @@ -220,3 +222,7 @@ function trim(str: string, ch: string) { return (start > 0 || end < str.length) ? str.substring(start, end) : str; } + +function isDirEmpty(dir: string): boolean { + return fs.readdirSync(dir).length == 0; +} \ No newline at end of file