-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (49 loc) · 1.65 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
53
54
55
56
#!/usr/bin/env node
import { cwd } from 'process';
import inquirer from 'inquirer';
import chalk from 'chalk';
import { simpleGit as git } from 'simple-git';
import autoComplete from 'inquirer-autocomplete-prompt';
const simpleGit = git(cwd());
console.log(cwd());
import deleteSquashMergedBranches from './delete-squashed-merged-branches.js';
inquirer.registerPrompt('autocomplete', autoComplete);
const run = async () => {
const branchInfo = await simpleGit.branch();
const branches = branchInfo.all;
const answers = await inquirer.prompt([
{
type: 'autocomplete',
name: 'baseBranch',
message: `Pick your ${chalk.red(
'base branch'
)}. We'll check if your feature branches can be deleted based on if their changesets are found in the ${chalk.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();
export default run;