Error log option

This commit is contained in:
Klemek
2019-06-22 10:02:25 +02:00
parent c90d573f11
commit 705dafa4e4
6 changed files with 66 additions and 8 deletions
+11 -2
View File
@@ -4,12 +4,21 @@ const path = require('path');
const deleteFolderSync = (dir) => {
if (!fs.existsSync(dir))
return;
fs.readdirSync(dir, {withFileTypes: true}).forEach((item) => {
let items;
const deleteItem = (item) => {
if (item.isDirectory())
deleteFolderSync(path.join(dir, item.name));
else
fs.unlinkSync(path.join(dir, item.name));
});
};
do {
items = fs.readdirSync(dir, {withFileTypes: true});
try {
items.forEach(deleteItem);
} catch (e) {
console.error(e);
}
} while (items.length > 0);
fs.rmdirSync(dir);
};