diff --git a/src/standaloneUtils/rmDuplicates.js b/src/standaloneUtils/rmDuplicates.js index 3bc4fa2..25b51da 100644 --- a/src/standaloneUtils/rmDuplicates.js +++ b/src/standaloneUtils/rmDuplicates.js @@ -125,7 +125,7 @@ function removePossibleAnswersDuplicates(path) { } const dataB = utils.ReadJSON(currPath2) - dataB.questions.forEach((q2) => { + dataB.questions.some((q2) => { const percent = compareQuestionObj( createQuestion(q1), '', @@ -136,6 +136,7 @@ function removePossibleAnswersDuplicates(path) { utils.deleteFile(currPath2) count-- delets++ + return true } }) }) @@ -143,7 +144,27 @@ function removePossibleAnswersDuplicates(path) { printProgressBar(currIndex, count) }) - log(`Deleted ${C('green')}${delets}${C()} files`) + + log(`${C('green')}Deleting empty directories ...${C()}`) + const dirs = fs.readdirSync(path) + count = dirs.length + currIndex = 0 + let deletedDirCount = 0 + dirs.forEach((dir) => { + currIndex++ + const currDirContent = fs.readdirSync(path + '/' + dir) + if (currDirContent.length === 0) { + fs.rmdirSync(path + '/' + dir) + deletedDirCount++ + } + printProgressBar(currIndex, count) + }) + + log( + `Deleted ${C('green')}${delets}${C()} files, and ${C( + 'green' + )}${deletedDirCount}${C()} directories` + ) } function clearPossibleAnswers(path, db) {