From abd0e4282ba30f6108fcf7d3449e8494fc543631 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 6 Jun 2019 01:57:31 +0200 Subject: [PATCH] IMPROVE the reset script, it's now safe! won't permanently delete files --- package.json | 1 + scripts/bootstrap.js | 2 +- scripts/reset.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3a05f6e45064..646d74e44804 100644 --- a/package.json +++ b/package.json @@ -147,6 +147,7 @@ "core-js": "^3.0.1", "cross-env": "^5.2.0", "danger": "^7.0.15", + "del": "^4.1.1", "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.9.1", "eslint": "^5.14.1", diff --git a/scripts/bootstrap.js b/scripts/bootstrap.js index 13bf6a994e2a..d30a28bd27ef 100755 --- a/scripts/bootstrap.js +++ b/scripts/bootstrap.js @@ -88,7 +88,7 @@ const tasks = { option: '--reset', command: () => { log.info(prefix, 'git clean'); - spawn('git clean -fdx --exclude=".vscode" --exclude=".idea"'); + spawn('node -r esm ./scripts/reset.js'); }, order: 0, }), diff --git a/scripts/reset.js b/scripts/reset.js index 96f41a74f411..05f3b8bb7a51 100644 --- a/scripts/reset.js +++ b/scripts/reset.js @@ -1,6 +1,7 @@ import fs from 'fs'; import { spawn, exec } from 'child_process'; import trash from 'trash'; +import del from 'del'; fs.writeFileSync('reset.log', ''); @@ -22,7 +23,15 @@ cleaningProcess.stdout.on('data', data => { const [, uri] = i.match(/Would remove (.*)$/) || []; if (uri) { - trash(uri); + if (uri.match(/node_modules/)) { + del(uri).then(() => { + console.log('deleted ' + uri); + }); + } else { + trash(uri).then(() => { + console.log('trashed ' + uri); + }); + } } }); }