From 29b7afe3889cd1fb5cae1e5959375175fc58a419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hegyi=20=C3=81ron=20Ferenc?= Date: Sun, 29 Oct 2023 23:10:37 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20missing=20format=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 01980ce..cfe3000 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,7 +40,9 @@ export const main = defineCommand({ else config = C.defaultConfig - if (!config.format.match(/{emoji}|{type}|{subject}/g)) + if (!config.format) + throw new Error('Format missing in config file.') + else if (!config.format.match(/{emoji}|{type}|{subject}/g)) throw new Error('Invalid format specified in config file.') // modify the commit message @@ -48,8 +50,7 @@ export const main = defineCommand({ const commitMessage = fs.readFileSync(commitMessageFilePath, 'utf-8') const firstLine = commitMessage.split('\n')[0] ?? '' - // the separator is whatever character remains after removing the format placeholders, - // if nothing remains, then the separator is a space + // the separator is whatever character remains after removing the format placeholders, or a space const separator = config.format.replace(/{emoji}|{type}|{subject}/g, '').trim() || ' ' let [type, subject] = firstLine.split(separator)