Merge pull request #5874 from spalger/implement/npmCleanTask
[npm] added "clean" script
This commit is contained in:
commit
383981a962
|
@ -57,7 +57,8 @@
|
|||
"lint": "grunt eslint:source",
|
||||
"lintroller": "grunt eslint:fixSource",
|
||||
"mocha": "mocha",
|
||||
"mocha:debug": "mocha --debug-brk"
|
||||
"mocha:debug": "mocha --debug-brk",
|
||||
"sterilize": "grunt sterilize"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
39
tasks/sterilize.js
Normal file
39
tasks/sterilize.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { bgRed, white } from 'ansicolors';
|
||||
import { execSync } from 'child_process';
|
||||
import { createInterface } from 'readline';
|
||||
|
||||
export default function (grunt) {
|
||||
|
||||
grunt.registerTask('sterilize', function () {
|
||||
|
||||
const cmd = 'git clean -fdx';
|
||||
const ignores = [
|
||||
'.aws-config.json',
|
||||
'config/kibana.dev.yml'
|
||||
]
|
||||
.concat(String(grunt.option('ignore') || '').split(','))
|
||||
.map(f => `-e "${f.split('"').join('\\"')}"`)
|
||||
.reduce((all, arg) => `${all} ${arg}`, '');
|
||||
|
||||
const stdio = 'inherit';
|
||||
execSync(`${cmd} -n ${ignores}`, { stdio });
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
const danger = bgRed(white('DANGER'));
|
||||
|
||||
rl.on('close', this.async());
|
||||
rl.question(`\n${danger} Do you really want to delete all of the above files?, [N/y] `, function (resp) {
|
||||
var yes = resp.toLowerCase().trim()[0] === 'y';
|
||||
rl.close();
|
||||
|
||||
if (yes) {
|
||||
execSync(`${cmd} ${ignores}`, { stdio });
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in a new issue