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

@@ -1,23 +1,33 @@
const path = x => require("../" + x);
const branch = path("js/branch");
const commander = path("js/commander");
let lib;
function validateCurrentBranch(dp) {
function currentIsStandardBranch(dp) {
if (branch.isNonStandard(dp.branch.current)) {
throw `invalid base branch: ${dp.branch.current}`;
const branches = branch
.standard()
.sort()
.join(", ");
throw `ERROR: starting branch must be one of: ${branches}`;
} else {
return dp;
}
}
function validateFeatureName(dp) {
function featureIsNotStandardBranch(dp) {
if (branch.isStandard(commander.featureName())) {
throw `invalid feature branch: ${commander.featureName()}`;
const branches = branch
.standard()
.sort()
.join(", ");
throw `ERROR: feature branch cannot be any of: ${branches}`;
} else {
return dp;
}
}
lib = { validateCurrentBranch, validateFeatureName };
lib = { currentIsStandardBranch, featureIsNotStandardBranch };
module.exports = lib;