Skip to content

Commit

Permalink
fix(cz-git): fix empty custom output '___CUSTOM___' value
Browse files Browse the repository at this point in the history
link #55
  • Loading branch information
Zhengqbbb committed Aug 15, 2022
1 parent 790a0f5 commit d1475d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/cz-git/src/generator/message.ts
Expand Up @@ -45,6 +45,12 @@ const getSingleParams = (answers: Answers, options: CommitizenGitOptions) => {
return mapping
}

const getCustomValue = (originVal?: string | string [], customVal?: string) => {
if (Array.isArray(originVal))
return originVal
return originVal !== '___CUSTOM___' ? originVal || '' : customVal || ''
}

const addType = (type: string, colorize?: boolean) => (colorize ? style.green(type) : type)

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

const { customScope, customFooterPrefixs } = answers
answers.scope = (answers.scope === '___CUSTOM___' && customScope) || answers.scope
answers.footerPrefix
= (answers.footerPrefix === '___CUSTOM___' && customFooterPrefixs) || answers.footerPrefix
answers.scope = getCustomValue(answers.scope, customScope)
answers.footerPrefix = getCustomValue(answers.footerPrefix, customFooterPrefixs) as string

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

0 comments on commit d1475d5

Please sign in to comment.