Skip to content

Commit

Permalink
feat(cz-git,cli): confirm message subject colorizen themeColorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhengqbbb committed Jul 8, 2023
1 parent 4bd33f5 commit 723dfe8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/cz-git/src/generator/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
*/
import { spawnSync } from 'node:child_process'
import { style } from '@cz-git/inquirer'
import { getCurrentScopes, getMaxSubjectLength, isSingleItem, parseStandardScopes, wrap } from '../shared'
import {
getCurrentScopes,
getMaxSubjectLength,
isSingleItem,
parseStandardScopes,
useThemeCode,
wrap,
} from '../shared'
import type { Answers, CommitizenGitOptions, GenerateAIPromptType } from '../shared'
import { fetchOpenAIMessage } from './api'

Expand Down Expand Up @@ -82,11 +89,13 @@ function addEmoji(emojiCode: string, align: string, emojiAlign?: string) {
return align === 'center' ? `${emojiCode} ` : ''
}

function addSubject(subject?: string, colorize?: boolean) {
function addSubject(subject?: string, colorize?: boolean, themeColorCode?: string) {
if (!subject)
return ''
subject = colorize ? style.cyan(subject) : subject
return subject.trim()
if (!colorize)
return subject.trim()
else
return useThemeCode(subject, themeColorCode).trim()
}

function addFooter(footerSuffix: string, footerPrefix = '', colorize?: boolean) {
Expand Down Expand Up @@ -137,7 +146,7 @@ export function generateMessage(answers: Answers,
const emoji = getEmojiCode(answers.type || '', options)
const scope = addScope(singleScope || scopeSource, colorize)
const markBreaking = addBreakchangeMark(answers.markBreaking, colorize)
const subject = addSubject(answers.subject, colorize)
const subject = addSubject(answers.subject, colorize, options.themeColorCode)

const defaultHeader
= `${`${addEmoji(emoji, 'left', options.emojiAlign)}${type}${scope ? `(${scope})` : ''}${markBreaking}`
Expand Down

0 comments on commit 723dfe8

Please sign in to comment.