Skip to content

Commit 1a195dc

Browse files
committed
fix(config.ts): better logic for parsed env values
1 parent 5fb5ce2 commit 1a195dc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/commands/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const configValidators = {
4848
return value;
4949
},
5050
[CONFIG_KEYS.OPENCOMMIT_DESCRIPTION](value: any) {
51-
const parsedValue = typeof value === 'boolean' || value === 'true' ? value : 'false'
51+
const parsedValue = typeof value === 'boolean' ? value : value === 'true' ? true : false
5252
validateConfig(
5353
CONFIG_KEYS.OPENCOMMIT_DESCRIPTION,
5454
typeof parsedValue === 'boolean',
@@ -58,7 +58,7 @@ export const configValidators = {
5858
return parsedValue;
5959
},
6060
[CONFIG_KEYS.OPENCOMMIT_EMOJI](value: any) {
61-
const parsedValue = typeof value === 'boolean' || value === 'true' ? value : 'false'
61+
const parsedValue = typeof value === 'boolean' ? value : value === 'true' ? true : false
6262
validateConfig(
6363
CONFIG_KEYS.OPENCOMMIT_EMOJI,
6464
typeof parsedValue === 'boolean',

src/generateCommitMessageFromGitDiff.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ChatCompletionRequestMessageRoleEnum
44
} from 'openai';
55
import { api } from './api';
6-
import { CONFIG_KEYS, getConfig } from './commands/config';
6+
import { getConfig } from './commands/config';
77
import { mergeStrings } from './utils/mergeStrings';
88

99
const config = getConfig();
@@ -12,11 +12,11 @@ const INIT_MESSAGES_PROMPT: Array<ChatCompletionRequestMessage> = [
1212
{
1313
role: ChatCompletionRequestMessageRoleEnum.System,
1414
content: `You are to act as the author of a commit message in git. Your mission is to create clean and comprehensive commit messages in the conventional commit convention. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message. ${
15-
config?.[CONFIG_KEYS.OPENCOMMIT_EMOJI]
15+
config?.OPENCOMMIT_EMOJI
1616
? 'Use Gitmoji convention to preface the commit'
1717
: 'Do not preface the commit with anything'
1818
}, use the present tense. ${
19-
config?.[CONFIG_KEYS.OPENCOMMIT_DESCRIPTION]
19+
config?.OPENCOMMIT_DESCRIPTION
2020
? 'Add a short description of what commit is about after the commit message. Don\'t start it with "This commit", just describe the changes.'
2121
: "Don't add any descriptions to the commit, only commit message."
2222
}`
@@ -49,9 +49,9 @@ const INIT_MESSAGES_PROMPT: Array<ChatCompletionRequestMessage> = [
4949
{
5050
role: ChatCompletionRequestMessageRoleEnum.Assistant,
5151
// prettier-ignore
52-
content: `${config?.[CONFIG_KEYS.OPENCOMMIT_EMOJI] ? '🐛 ' : ''}fix(server.ts): change port variable case from lowercase port to uppercase PORT
53-
${config?.[CONFIG_KEYS.OPENCOMMIT_EMOJI] ? '✨ ' : ''}feat(server.ts): add support for process.env.PORT environment variable
54-
${config?.[CONFIG_KEYS.OPENCOMMIT_DESCRIPTION] ? 'The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable.' : ''}`
52+
content: `${config?.OPENCOMMIT_EMOJI ? '🐛 ' : ''}fix(server.ts): change port variable case from lowercase port to uppercase PORT
53+
${config?.OPENCOMMIT_EMOJI ? '✨ ' : ''}feat(server.ts): add support for process.env.PORT environment variable
54+
${config?.OPENCOMMIT_DESCRIPTION ? 'The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable.' : ''}`
5555
}
5656
];
5757

0 commit comments

Comments
 (0)