From 5c14190f5e73838a4ccf5afee3c972d1687adf3d Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sun, 16 Jun 2019 21:07:37 +0200 Subject: [PATCH] IMPROVE reset script --- scripts/reset.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/reset.js b/scripts/reset.js index 59f77675dc30..85ce5358b488 100644 --- a/scripts/reset.js +++ b/scripts/reset.js @@ -23,14 +23,19 @@ cleaningProcess.stdout.on('data', data => { const [, uri] = i.match(/Would remove (.*)$/) || []; if (uri) { - if (uri.match(/node_modules/)) { + if (uri.match(/\/node_modules\//) || uri.match(/\/dist\//)) { del(uri).then(() => { console.log(`deleted ${uri}`); }); } else { - trash(uri).then(() => { - console.log(`trashed ${uri}`); - }); + trash(uri) + .then(() => { + console.log(`trashed ${uri}`); + }) + .catch(e => { + console.log('failed to trash, will try permanent delete'); + trash(uri); + }); } } });