Release v1.3.0 #5
33
src/index.ts
33
src/index.ts
@@ -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();
|
program.parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user