From a2d03e054c4a6db1b77292b7682b0fdc4244c643 Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Tue, 28 Mar 2023 11:31:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20chore(CommandsEnum.ts):=20reorde?= =?UTF-8?q?r=20COMMANDS=20enum=20values=20=F0=9F=90=9B=20fix(config.ts):?= =?UTF-8?q?=20add=20missing=20new=20lines=20=F0=9F=90=9B=20fix(githook.ts)?= =?UTF-8?q?:=20capitalize=20OpenCommit=20and=20fix=20grammar=20The=20COMMA?= =?UTF-8?q?NDS=20enum=20values=20were=20reordered=20to=20improve=20readabi?= =?UTF-8?q?lity=20and=20consistency.=20In=20config.ts,=20missing=20new=20l?= =?UTF-8?q?ines=20were=20added=20to=20improve=20code=20readability.=20In?= =?UTF-8?q?=20githook.ts,=20OpenCommit=20was=20capitalized=20and=20grammar?= =?UTF-8?q?=20was=20fixed=20to=20improve=20clarity.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CommandsEnum.ts | 4 ++-- src/commands/config.ts | 4 ++++ src/commands/githook.ts | 6 +++--- src/generateCommitMessageFromGitDiff.ts | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CommandsEnum.ts b/src/CommandsEnum.ts index d3667e5..c1e0b14 100644 --- a/src/CommandsEnum.ts +++ b/src/CommandsEnum.ts @@ -1,4 +1,4 @@ export enum COMMANDS { - config = 'config', - hook = 'hook' + hook = 'hook', + config = 'config' } diff --git a/src/commands/config.ts b/src/commands/config.ts index e0a7123..c10ed41 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -29,6 +29,7 @@ const validateConfig = ( outro( `${chalk.red('✖')} Unsupported config key ${key}: ${validationMessage}` ); + process.exit(1); } }; @@ -49,6 +50,7 @@ export const configValidators = { return value; }, + [CONFIG_KEYS.description](value: any) { validateConfig( CONFIG_KEYS.description, @@ -58,6 +60,7 @@ export const configValidators = { return value; }, + [CONFIG_KEYS.emoji](value: any) { validateConfig( CONFIG_KEYS.emoji, @@ -67,6 +70,7 @@ export const configValidators = { return value; }, + [CONFIG_KEYS.language](value: any) { validateConfig( CONFIG_KEYS.language, diff --git a/src/commands/githook.ts b/src/commands/githook.ts index 02ac98e..e6f2dfd 100644 --- a/src/commands/githook.ts +++ b/src/commands/githook.ts @@ -55,18 +55,18 @@ export const hookCommand = command( } if (mode === 'unset') { - intro(`unsetting opencommit as '${HOOK_NAME}' hook`); + intro(`unsetting OpenCommit as '${HOOK_NAME}' hook`); if (!isHookExists) { return outro( - `opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove` + `OpenCommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove` ); } const realpath = await fs.realpath(SYMLINK_URL); if (realpath !== HOOK_URL) { return outro( - `opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually` + `OpenCommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually` ); } diff --git a/src/generateCommitMessageFromGitDiff.ts b/src/generateCommitMessageFromGitDiff.ts index d310c01..69100b0 100644 --- a/src/generateCommitMessageFromGitDiff.ts +++ b/src/generateCommitMessageFromGitDiff.ts @@ -8,7 +8,7 @@ import { mergeStrings } from './utils/mergeStrings'; import { i18n, I18nLocals } from './i18n'; const config = getConfig(); -const translation = i18n[config?.language as I18nLocals || 'en'] +const translation = i18n[(config?.language as I18nLocals) || 'en']; const INIT_MESSAGES_PROMPT: Array = [ { @@ -20,7 +20,7 @@ const INIT_MESSAGES_PROMPT: Array = [ }, use the present tense. ${ config?.description ? 'Add a short description of what commit is about after the commit message. Don\'t start it with "This commit", just describe the changes.' - : 'Don\'t add any descriptions to the commit, only commit message.' + : "Don't add any descriptions to the commit, only commit message." } Use ${translation.localLanguage} to answer.` }, {