From 728212010f8028623deeeb7773ed5a5d7433a8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Fri, 18 Mar 2022 10:29:21 +0100 Subject: [PATCH] Fix empty challenge directory error It occured after moving back from challenge branch to the main. --- scripts/build.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/build.js b/scripts/build.js index f519fcb4..9f018744 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,8 +1,16 @@ const { readdirSync } = require('fs') +const { resolve } = require('path') + +const isDirEmpty = (directory, subdirectory) => { + const path = resolve(directory, subdirectory) + return readdirSync(path).length === 0 +} const getDirectories = (source) => readdirSync(source, { withFileTypes: true }) - .filter((dirent) => dirent.isDirectory()) + .filter( + (dirent) => dirent.isDirectory() && !isDirEmpty(source, dirent.name) + ) .map((dirent) => dirent.name) const foreachChallenge = (command) => {