-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (26 loc) · 738 Bytes
/
index.js
File metadata and controls
27 lines (26 loc) · 738 Bytes
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
const path = require('path');
const _ = require('lodash');
const async = require('async');
const inquirer = require('inquirer');
const simpleGit = require('simple-git')(process.cwd());
async.autoInject({
git: (callback) => {
simpleGit.branchLocal(callback)
},
pick: (git, callback) => {
debugger;
const choices = _.values(git.branches).map((branch) => branch.current ? `* ${branch.name}` : branch.name);
inquirer.prompt({
name: 'branch',
type: 'list',
message: 'Pick Branch',
choices,
}).then(({ branch }) => callback(undefined, branch));
},
switch: (pick, callback) => {
if (pick.indexOf('*') === 0) {
process.exit(0);
}
simpleGit.checkout(pick, callback);
}
})