Skip to content

Commit

Permalink
IMPROVE the reset script, it's now safe! won't permanently delete files
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 5, 2019
1 parent 55a7bf1 commit abd0e42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
11 changes: 10 additions & 1 deletion scripts/reset.js
Original file line number Diff line number Diff line change
@@ -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', '');

Expand All @@ -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);
});
}
}
});
}
Expand Down

0 comments on commit abd0e42

Please sign in to comment.