From 765d05b79e74e7094cdddf38d1b764dfa2ed75b0 Mon Sep 17 00:00:00 2001 From: Ashton Eby Date: Tue, 22 Oct 2024 12:55:33 -0700 Subject: [PATCH] bug: fix issues with commit message parsing --- package-lock.json | 7 +++++++ package.json | 1 + scripts/version-bump.js | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc79320..aedb904 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.1", "license": "MPL-2.0", "dependencies": { + "mentions-regex": "^2.0.3", "parse-commit-message": "^5.0.4" } }, @@ -17,6 +18,12 @@ "resolved": "https://registry.npmjs.org/collect-mentions/-/collect-mentions-2.0.1.tgz", "integrity": "sha512-3/MkmIZDerSapDxlRLGJ2M38Zs2+GMJ6i3X4d9ilyB82PcSFVzA5VVH6A6SKXPIuzcyeE+xAS+4XdY0O1MVAxQ==" }, + "node_modules/mentions-regex": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/mentions-regex/-/mentions-regex-2.0.3.tgz", + "integrity": "sha512-136g0tOWk7/Y7LK/Y6FZa6TxLqwxFCAUoY6z/GC5o5ulK8oXzEU4knnTAoeVscQUTTEkNCOZcKWSxkCNmgSWHQ==", + "license": "MIT" + }, "node_modules/mixin-deep": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-2.0.1.tgz", diff --git a/package.json b/package.json index 0cb276f..f5dd7e7 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "homepage": "https://github.com/fauna/typescript#readme", "dependencies": { + "mentions-regex": "^2.0.3", "parse-commit-message": "^5.0.4" } } diff --git a/scripts/version-bump.js b/scripts/version-bump.js index 20dfb11..0e91cce 100755 --- a/scripts/version-bump.js +++ b/scripts/version-bump.js @@ -3,10 +3,17 @@ const { execSync } = require('node:child_process'); const { parseHeader } = require('parse-commit-message'); -const latestCommitMessage = execSync("git log -1 --pretty=%B"); -const { type, scope } = parseHeader(latestCommitMessage); +const latestCommitMessage = execSync("git log -1 --pretty=%B", { encoding: "utf-8" }); +let flag, type, scope; + +try { + console.log("latestCommitMessage", latestCommitMessage); + ({ type, scope }) = parseHeader(latestCommitMessage); +} catch (e) { + scope = undefined; + type = undefined; +} -let flag; if (scope === 'patch' || ['fix', 'chore', 'docs', 'refactor', 'perf', 'test', 'build'].includes(type)) { flag = '--patch'; } else if (scope === 'minor' || ['feat', 'feature'].includes(type)) {