Skip to content

Commit

Permalink
fix(cz-git): fix custom scope skip allowEmptyScopes check
Browse files Browse the repository at this point in the history
link #16
  • Loading branch information
Zhengqbbb committed Apr 23, 2022
1 parent 5a1881d commit f0d8c53
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/cz-git/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
name: "scope",
message: options.messages?.customScope,
default: options.defaultScope || undefined,
validate(input: string) {
if (options.allowEmptyScopes) return true;
return input.length ? true : "\u001B[1;31m[ERROR] scope is required\u001B[0m";
},
when(answers: Answers) {
return answers.scope === "___CUSTOM___";
}
Expand Down Expand Up @@ -170,14 +174,14 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
else tooltip = `${maxSubjectLength - subjectLength} more chars allowed`;
const tooltipColor =
minSubjectLength !== undefined &&
subjectLength >= minSubjectLength &&
subjectLength <= maxSubjectLength
subjectLength >= minSubjectLength &&
subjectLength <= maxSubjectLength
? "\u001B[90m"
: "\u001B[31m";
const subjectColor =
minSubjectLength !== undefined &&
subjectLength >= minSubjectLength &&
subjectLength <= maxSubjectLength
subjectLength >= minSubjectLength &&
subjectLength <= maxSubjectLength
? "\u001B[36m"
: "\u001B[31m";

Expand Down Expand Up @@ -229,7 +233,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
options.customIssuePrefixsAlias,
options.allowCustomIssuePrefixs,
options.allowEmptyIssuePrefixs
)
);
return issues?.filter((item) => (input ? item.name?.includes(input) : true)) || true;
}
},
Expand Down

0 comments on commit f0d8c53

Please sign in to comment.