mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
42 lines
810 B
JavaScript
42 lines
810 B
JavaScript
|
import fs from 'fs';
|
||
|
import { spawn, exec } from 'child_process';
|
||
|
import trash from 'trash';
|
||
|
|
||
|
fs.writeFileSync('reset.log', '');
|
||
|
|
||
|
// let results = [];
|
||
|
const cleaningProcess = spawn('git', [
|
||
|
'clean',
|
||
|
'-xdf',
|
||
|
'-n',
|
||
|
'--exclude=".vscode"',
|
||
|
'--exclude=".idea"',
|
||
|
]);
|
||
|
|
||
|
cleaningProcess.stdout.on('data', data => {
|
||
|
if (data && data.toString()) {
|
||
|
const l = data
|
||
|
.toString()
|
||
|
.split(/\n/)
|
||
|
.forEach(i => {
|
||
|
const [, uri] = i.match(/Would remove (.*)$/) || [];
|
||
|
|
||
|
if (uri) {
|
||
|
trash(uri);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
fs.appendFile('reset.log', data, err => {
|
||
|
if (err) {
|
||
|
throw err;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
cleaningProcess.on('exit', code => {
|
||
|
if (code === 0) {
|
||
|
console.log('all went well, files are being trashed now');
|
||
|
} else {
|
||
|
console.error(code);
|
||
|
}
|
||
|
});
|