Skip to content

Commit d1475d5

Browse files
committed
fix(cz-git): fix empty custom output '___CUSTOM___' value
link #55
1 parent 790a0f5 commit d1475d5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎packages/cz-git/src/generator/message.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const getSingleParams = (answers: Answers, options: CommitizenGitOptions) => {
4545
return mapping
4646
}
4747

48+
const getCustomValue = (originVal?: string | string [], customVal?: string) => {
49+
if (Array.isArray(originVal))
50+
return originVal
51+
return originVal !== '___CUSTOM___' ? originVal || '' : customVal || ''
52+
}
53+
4854
const addType = (type: string, colorize?: boolean) => (colorize ? style.green(type) : type)
4955

5056
const addScope = (scope?: string, colorize?: boolean) => {
@@ -109,9 +115,8 @@ export const generateMessage = (
109115
}
110116

111117
const { customScope, customFooterPrefixs } = answers
112-
answers.scope = (answers.scope === '___CUSTOM___' && customScope) || answers.scope
113-
answers.footerPrefix
114-
= (answers.footerPrefix === '___CUSTOM___' && customFooterPrefixs) || answers.footerPrefix
118+
answers.scope = getCustomValue(answers.scope, customScope)
119+
answers.footerPrefix = getCustomValue(answers.footerPrefix, customFooterPrefixs) as string
115120

116121
const { singleScope, singeIssuePrefix } = getSingleParams(answers, options)
117122
const scope = Array.isArray(answers.scope)

0 commit comments

Comments
 (0)