#!/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));