Release v1.3.0 #5

Merged
CTO merged 5 commits from develop into main 2023-08-21 15:14:27 +00:00
Showing only changes of commit 9311be80b2 - Show all commits

View File

@@ -407,4 +407,37 @@ program
);
});
program
.command("validate")
.description("Validate whether a string fits given commit conventions")
.argument("[message]", "string for validation")
.action(async (string: string) => {
try {
const message = string || fs.readFileSync(0, "utf-8");
const config = await GetConfig();
// Regex for testing:
// /(build|feat|docs)(\((commands|changelog)\))?!?: .* ?(\(..*\))?((\n\n..*)?(\n\n..*)?)?/gm
const testRegex = new RegExp(
`(${
config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor"
})(\\((${
config?.scopes?.join("|") || "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm"
);
console.log(
testRegex.test(message)
? "[rcz]: valid message"
: "[rcz]: invalid message"
);
} catch (err) {
console.log("[rcz]: no stdin found");
}
});
program.parse();