From d597265ba7628fcba9de27cc453aeb4deee3a0a1 Mon Sep 17 00:00:00 2001 From: Irfan Maulana Date: Wed, 26 Feb 2020 14:50:18 +0700 Subject: [PATCH] Update purge.js --- purge.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/purge.js b/purge.js index fc7675766..749c5b209 100644 --- a/purge.js +++ b/purge.js @@ -8,11 +8,14 @@ const peoplesPath = path.join(__dirname, "peoples"); if (!namesToRemove.length) { fs.readdirSync(peoplesPath).forEach(file => { if (file.indexOf('mazipan.js') < 0) { - fs.unlinkSync(path.join(peoplesPath, file)) + try{ + fs.unlinkSync(path.join(peoplesPath, file)); + console.log(`Success deleting file: ${file}`); + }catch (e) { + console.error(`Error deleting file: ${file}`); + } } }); - - fs.rmdirSync(peoplesPath); } else { namesToRemove.forEach(name => { try { @@ -21,6 +24,4 @@ if (!namesToRemove.length) { console.error(`Error deleting file for name: ${name}`); } }); - - fs.rmdirSync(peoplesPath); }