Merge pull request 'Add the ability to return only the code of validation command' (#6) from develop into main
Reviewed-on: technology/rcz#6
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
Generation of this changelog is based on commits
|
||||
|
||||
## v1.4.0
|
||||
|
||||
### Features
|
||||
|
||||
- [8ab631549] - **commands**: add the ability to return code only for validation command
|
||||
|
||||
## v1.3.0
|
||||
|
||||
### Features
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@resultium/rcz",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Resultium commit standardization library, based on conventional commits",
|
||||
"main": "./dist/index.js",
|
||||
"bin": {
|
||||
|
||||
10
src/index.ts
10
src/index.ts
@@ -33,7 +33,7 @@ const program = new Command();
|
||||
program
|
||||
.name("rcz")
|
||||
.description("Resultium commit standardization command-line interface")
|
||||
.version("1.3.0");
|
||||
.version("1.4.0");
|
||||
|
||||
program
|
||||
.command("commit")
|
||||
@@ -420,9 +420,11 @@ program
|
||||
.command("validate")
|
||||
.description("Validate whether a string fits given commit conventions")
|
||||
.argument("[message]", "string for validation")
|
||||
.action(async (string: string) => {
|
||||
.option("-C, --code-only", "return code only")
|
||||
.action(async (string: string, options) => {
|
||||
try {
|
||||
const message = string || fs.readFileSync(0, "utf-8");
|
||||
const codeOnly = options.codeOnly ? true : false;
|
||||
|
||||
const config = await GetConfig();
|
||||
|
||||
@@ -439,11 +441,15 @@ program
|
||||
"gm"
|
||||
);
|
||||
|
||||
if (codeOnly) {
|
||||
console.log(testRegex.test(message) ? 0 : 1);
|
||||
} else {
|
||||
console.log(
|
||||
testRegex.test(message)
|
||||
? "[rcz]: valid message"
|
||||
: "[rcz]: invalid message"
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("[rcz]: no stdin found");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user