Skip to content

Commit

Permalink
🚑 Don't include undefined in message body (#1083)
Browse files Browse the repository at this point in the history
* 🚑 Make sure we don't write undefined in the message body

* 🎨 Construct args in one go
  • Loading branch information
segersniels authored May 9, 2023
1 parent ed57cba commit c6561ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/commands/commit/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Answers = {
gitmoji: string,
scope?: string,
title: string,
message: string
message?: string
}

export default (
Expand Down
7 changes: 6 additions & 1 deletion src/commands/commit/withClient/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const withClient = async (answers: Answers): Promise<void> => {

await execa(
'git',
['commit', isAutoAddEnabled ? '-am' : '-m', title, '-m', answers.message],
[
'commit',
isAutoAddEnabled ? '-am' : '-m',
title,
...(answers.message ? ['-m', answers.message] : [])
],
{
buffer: false,
stdio: 'inherit'
Expand Down
4 changes: 3 additions & 1 deletion src/commands/commit/withHook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const withHook = (answers: Answers) => {
try {
const scope = answers.scope ? `(${answers.scope}): ` : ''
const title = `${answers.gitmoji} ${scope}${answers.title}`
const commitMessage = `${title}\n\n${answers.message}`
const commitMessage = `${title}${
answers.message ? `\n\n${answers.message}` : ''
}`

fs.writeFileSync(process.argv[3], commitMessage)
} catch (error) {
Expand Down

0 comments on commit c6561ee

Please sign in to comment.