[F] fix empty dir crash build

pull/227/head
Elihuso Quigley 2024-05-25 20:14:37 +08:00
parent 10de8cb4ad
commit 7ed05525b5
1 changed files with 6 additions and 0 deletions

View File

@ -53,6 +53,7 @@ function buildPeopleInfoAndList() {
for (const { dirname, srcPath, distPath } of people) { for (const { dirname, srcPath, distPath } of people) {
if (excludeList.includes(dirname)) continue; if (excludeList.includes(dirname)) continue;
if (isDirEmpty(srcPath)) continue;
const infoFile = fs.readFileSync(path.join(srcPath, `info.yml`), "utf-8"); const infoFile = fs.readFileSync(path.join(srcPath, `info.yml`), "utf-8");
const info: any = YAML.load(infoFile); const info: any = YAML.load(infoFile);
@ -132,6 +133,7 @@ function buildPeoplePages() {
for (const { dirname, srcPath, distPath } of people) { for (const { dirname, srcPath, distPath } of people) {
if (excludeList.includes(dirname)) continue; if (excludeList.includes(dirname)) continue;
if (isDirEmpty(srcPath)) continue;
for (const lang of ['', '.zh_hant', '.en']) 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; return (start > 0 || end < str.length) ? str.substring(start, end) : str;
} }
function isDirEmpty(dir: string): boolean {
return fs.readdirSync(dir).length == 0;
}