kibana/tasks/sterilize.js
archana a03e37cb9c
[CLI] Readable logs on Windows with chalk colors (#15557) (#17636)
* [colors] try new cli colors

* [colors] try magentaBright instead of magenta

* [colors] try white for log text

* [colors] replace all remaining ansicolors with chalk

* [colors] try yellowBright instead of yellow

* remove ansicolors from package.json

* [tests] attempt to fix tests

* [tests] attempt to fix tests again

* [color] backgrounds, cleanup

* [color] update yarn.lock
2018-04-10 10:57:56 -05:00

40 lines
1 KiB
JavaScript

import { bgRed, white } from 'chalk';
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) {
const yes = resp.toLowerCase().trim()[0] === 'y';
rl.close();
if (yes) {
execSync(`${cmd} ${ignores}`, { stdio });
}
});
});
}