@@ -10,11 +10,11 @@ import {
1010 getMaxSubjectLength ,
1111 handleStandardScopes ,
1212 handleCustomTemplate ,
13- buildCommit ,
1413 log ,
1514 isSingleItem ,
1615 getCurrentScopes
1716} from "../shared" ;
17+ import { generateMessage } from "./build" ;
1818
1919export const generateQuestions = ( options : CommitizenGitOptions , cz : any ) => {
2020 if ( ! Array . isArray ( options . types ) || options . types . length === 0 ) {
@@ -53,7 +53,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
5353 ) ;
5454 return scopes ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
5555 } ,
56- when ( answer : Answers ) {
56+ when : ( answer : Answers ) => {
5757 return ! isSingleItem (
5858 options . allowCustomScopes ,
5959 options . allowEmptyScopes ,
@@ -68,19 +68,19 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
6868 name : "scope" ,
6969 message : options . messages ?. customScope ,
7070 default : options . defaultScope || undefined ,
71- validate ( input : string ) {
71+ validate : ( input : string ) => {
7272 if ( options . allowEmptyScopes ) return true ;
7373 return input . length ? true : "\u001B[1;31m[ERROR] scope is required\u001B[0m" ;
7474 } ,
75- when ( answers : Answers ) {
75+ when : ( answers : Answers ) => {
7676 return answers . scope === "___CUSTOM___" ;
7777 }
7878 } ,
7979 {
8080 type : "input" ,
8181 name : "subject" ,
8282 message : options . messages ?. subject ,
83- validate ( subject : string , answers : Answers ) {
83+ validate : ( subject : string , answers : Answers ) => {
8484 const processedSubject = getProcessSubject ( subject ) ;
8585 if ( processedSubject . length === 0 )
8686 return "\u001B[1;31m[ERROR] subject is required\u001B[0m" ;
@@ -120,7 +120,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
120120
121121 return `${ tooltipColor } [${ tooltip } ]\u001B[0m\n ${ subjectColor } ${ subject } \u001B[0m` ;
122122 } ,
123- filter ( subject : string ) {
123+ filter : ( subject : string ) => {
124124 const upperCaseSubject = options . upperCaseSubject || false ;
125125
126126 return (
@@ -141,7 +141,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
141141 name : "breaking" ,
142142 message : options . messages ?. breaking ,
143143 default : options . defaultBody || undefined ,
144- when ( answers : Answers ) {
144+ when : ( answers : Answers ) => {
145145 if (
146146 options . allowBreakingChanges &&
147147 answers . type &&
@@ -168,14 +168,20 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
168168 options . allowEmptyIssuePrefixs
169169 ) ;
170170 return issues ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
171- }
171+ } ,
172+ when : ( ) =>
173+ ! isSingleItem (
174+ options . allowCustomIssuePrefixs ,
175+ options . allowEmptyIssuePrefixs ,
176+ options . issuePrefixs
177+ )
172178 } ,
173179 {
174180 type : "input" ,
175181 name : "footerPrefix" ,
176182 message : options . messages ?. customFooterPrefixs ,
177183 default : options . defaultIssues || undefined ,
178- when ( answers : Answers ) {
184+ when : ( answers : Answers ) => {
179185 return answers . footerPrefix === "___CUSTOM___" ;
180186 }
181187 } ,
@@ -202,7 +208,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
202208 ? "\u001B[1;90m###--------------------------------------------------------###\u001B[0m"
203209 : "###--------------------------------------------------------###" ;
204210 console . info (
205- `\n${ SEP } \n${ buildCommit ( answers , options , options . confirmColorize ) } \n${ SEP } \n`
211+ `\n${ SEP } \n${ generateMessage ( answers , options , options . confirmColorize ) } \n${ SEP } \n`
206212 ) ;
207213 return options . messages ?. confirmCommit ;
208214 }
0 commit comments