Files
git-utilities/bin/creature-end
2019-07-20 08:11:08 -04:00

32 lines
777 B
JavaScript
Executable File

#!/usr/bin/env node
const _ = require("lodash");
const path = x => require("../" + x);
const git = path("js/git");
const shell = path("js/shell");
const commander = path("js/commander");
const validate = path("js/validate");
function endFeatureBranch(dp) {
const cmds = [
`git checkout ${dp.branch.standard}`,
`git branch -d ${dp.branch.current}`
];
const remoteBranch = _.get(dp, "branch.remote", false);
if (remoteBranch) {
cmds.push(`git push origin :${remoteBranch}`);
}
return shell.pipeline(cmds);
}
commander
.start()
.then(git.setCurrentBranch)
.then(git.parseCurrentBranch)
.then(validate.mustBeFeatureBranch)
.then(git.setStandardBranch)
.then(git.isBranchRemote)
.then(endFeatureBranch)
.catch(err => console.error(err));