This commit is contained in:
rkiel
2019-07-18 16:09:29 -04:00
parent 308d62fc86
commit 2443a88ad7
4 changed files with 48 additions and 42 deletions

View File

@@ -3,36 +3,10 @@
const _ = require("lodash");
const path = x => require("../" + x);
const immutable = path("js/immutable");
const git = path("js/git");
const shell = path("js/shell");
const commander = path("js/commander");
const branch = path("js/branch");
function validateCurrentBranch(dp) {
if (branch.isNonStandard(dp.branch.current)) {
throw `invalid base branch: ${dp.branch.current}`;
} else {
return dp;
}
}
function validateFeatureName(dp) {
if (branch.isStandard(commander.featureName())) {
throw `invalid feature branch: ${commander.featureName()}`;
} else {
return dp;
}
}
function setFeatureBranch(dp) {
const fb = [
commander.prefix(),
dp.branch.current,
commander.featureName()
].join("-");
return immutable.set(dp, "branch.feature", fb);
}
const validate = path("js/validate");
function createFeatureBranch(dp) {
return shell.pipeline([
@@ -44,14 +18,11 @@ function createFeatureBranch(dp) {
]);
}
function toPromise(dp) {
return Promise.resolve(dp);
}
const x = toPromise(commander.parse())
.then(validateFeatureName)
commander
.start()
.then(git.setCurrentBranch)
.then(validateCurrentBranch)
.then(setFeatureBranch)
.then(validate.currentIsStandardBranch)
.then(git.setFeatureBranch)
.then(validate.featureIsNotStandardBranch)
.then(createFeatureBranch)
.catch(err => console.error(err));