-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (47 loc) · 1.55 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
const process = require('process');
const inquirer = require('inquirer');
const { red } = require('chalk');
const simpleGit = require('simple-git/promise')(process.cwd());
console.log(process.cwd());
const deleteSquashMergedBranches = require('./delete-squashed-merged-branches');
inquirer.registerPrompt(
'autocomplete',
require('inquirer-autocomplete-prompt')
);
const run = async () => {
const branchInfo = await simpleGit.branch();
const branches = branchInfo.all;
const answers = await inquirer.prompt([
{
type: 'autocomplete',
name: 'baseBranch',
message: `Pick your ${red(
'base branch'
)}. We'll check if your feature branches can be deleted based on if their changesets are found in the ${red(
'base branch'
)}.`,
source: function(answersSoFar, input) {
return Promise.resolve(
input
? branches.filter(branch => branch.indexOf(input) > -1)
: branches
);
}
},
{
type: 'list',
name: 'runType',
message: 'What do you want to do with squash-merged we find?',
choices: [
{ name: 'List them out', value: 'dry' },
{ name: 'Actually delete them', value: 'delete' }
]
}
]);
return deleteSquashMergedBranches(
answers.baseBranch,
answers.runType === 'delete'
);
};
run();