@@ -184,12 +184,13 @@ export const handleScopes = (scopes: ScopesType): Option[] => {
184184 } ) ;
185185} ;
186186
187- const addType = ( type : string , color ?: boolean ) => ( color ? `\u001B[33m${ type } \u001B[0m` : type ) ;
187+ const addType = ( type : string , colorize ?: boolean ) =>
188+ colorize ? `\u001B[33m${ type } \u001B[0m` : type ;
188189
189- const addScope = ( scope ?: string , color ?: boolean ) => {
190+ const addScope = ( scope ?: string , colorize ?: boolean ) => {
190191 const separator = ":" ;
191192 if ( ! scope ) return separator ;
192- scope = color ? `\u001B[35m${ scope } \u001B[0m` : scope ;
193+ scope = colorize ? `\u001B[35m${ scope } \u001B[0m` : scope ;
193194 return `(${ scope . trim ( ) } )${ separator } ` ;
194195} ;
195196
@@ -202,36 +203,36 @@ const addEmoji = (type: string, options: CommitizenGitOptions): string => {
202203 }
203204} ;
204205
205- const addSubject = ( subject ?: string , color ?: boolean ) => {
206+ const addSubject = ( subject ?: string , colorize ?: boolean ) => {
206207 if ( ! subject ) return "" ;
207- subject = color ? `\u001B[36m${ subject } \u001B[0m` : subject ;
208+ subject = colorize ? `\u001B[36m${ subject } \u001B[0m` : subject ;
208209 return subject . trim ( ) ;
209210} ;
210211
211212const addBreaklinesIfNeeded = ( value : string , breaklineChar = "|" ) =>
212213 value . split ( breaklineChar ) . join ( "\n" ) . valueOf ( ) ;
213214
214- const addFooter = ( footer : string , footerPrefix = "" , color ?: boolean ) => {
215+ const addFooter = ( footer : string , footerPrefix = "" , colorize ?: boolean ) => {
215216 if ( footerPrefix === "" ) {
216- return color ? `\n\n\u001B[32m${ footer } \u001B[0m` : `\n\n${ footer } ` ;
217+ return colorize ? `\n\n\u001B[32m${ footer } \u001B[0m` : `\n\n${ footer } ` ;
217218 }
218- return color
219+ return colorize
219220 ? `\n\n\u001B[32m${ footerPrefix } ${ footer } \u001B[0m`
220221 : `\n\n${ footerPrefix } ${ footer } ` ;
221222} ;
222223
223- export const buildCommit = ( answers : Answers , options : CommitizenGitOptions , color = false ) => {
224+ export const buildCommit = ( answers : Answers , options : CommitizenGitOptions , colorize = false ) => {
224225 const wrapOptions = {
225226 trim : true ,
226227 newLine : "\n" ,
227228 indent : "" ,
228229 width : 100
229230 } ;
230231 const head =
231- addType ( answers . type ?? "" , color ) +
232- addScope ( answers . scope , color ) +
232+ addType ( answers . type ?? "" , colorize ) +
233+ addScope ( answers . scope , colorize ) +
233234 addEmoji ( answers . type ?? "" , options ) +
234- addSubject ( answers . subject , color ) ;
235+ addSubject ( answers . subject , colorize ) ;
235236 const body = wrap ( answers . body ?? "" , wrapOptions ) ;
236237 const breaking = wrap ( answers . breaking ?? "" , wrapOptions ) ;
237238 const footer = wrap ( answers . footer ?? "" , wrapOptions ) ;
@@ -244,7 +245,7 @@ export const buildCommit = (answers: Answers, options: CommitizenGitOptions, col
244245 result += `\n\nBREAKING CHANGE :\n${ addBreaklinesIfNeeded ( breaking , options . breaklineChar ) } ` ;
245246 }
246247 if ( footer ) {
247- result += addFooter ( footer , answers . footerPrefix , color ) ;
248+ result += addFooter ( footer , answers . footerPrefix , colorize ) ;
248249 }
249250 return result ;
250251} ;
0 commit comments