Skip to content

Commit 0c075af

Browse files
committed
refactor: add function to join by colon
1 parent edbda28 commit 0c075af

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/prepareCommitMsg.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import { parseDiffIndex } from "./git/parseOutput";
2020
import { AGGREGATE_MIN, CONVENTIONAL_TYPE } from "./lib/constants";
2121
import { equal } from "./lib/utils";
2222
import { ConvCommitMsg } from "./prepareCommitMsg.d";
23+
2324
/**
2425
* Join two strings together with a space.
2526
*
26-
* Use only one string if only one is set, or if they are identical.
27+
* Use only one string if only one is set or if they are identical.
2728
*
28-
* Trimming on the outside is necessary, in case only one item is set.
29+
* Trimming on the outside is necessary here, in case only one item is set.
2930
*/
3031
export function _cleanJoin(first: string, second: string) {
3132
first = first.trim();
@@ -37,6 +38,13 @@ export function _cleanJoin(first: string, second: string) {
3738
return `${first} ${second}`.trim();
3839
}
3940

41+
/**
42+
* Join two strings using a colon and space.
43+
*/
44+
export function _colonJoin(first: string, second: string): string {
45+
return `${first}: ${second}`;
46+
}
47+
4048
/**
4149
* Determine the Conventional Commit type prefix for a file change.
4250
*
@@ -162,7 +170,7 @@ export function _formatMsg(convCommitMsg: ConvCommitMsg) {
162170
if (convCommitMsg.typePrefix === CONVENTIONAL_TYPE.UNKNOWN) {
163171
return convCommitMsg.description;
164172
}
165-
return `${convCommitMsg.typePrefix}: ${convCommitMsg.description}`;
173+
return _colonJoin(convCommitMsg.typePrefix, convCommitMsg.description);
166174
}
167175

168176
/**
@@ -203,7 +211,7 @@ export function _joinOldAndNew(
203211
if (typePrefix) {
204212
const prefix = _cleanJoin(oldMsgPieces.customPrefix, typePrefix);
205213

206-
return `${prefix}: ${descResult}`;
214+
return _colonJoin(prefix, descResult);
207215
}
208216

209217
return descResult;

0 commit comments

Comments
 (0)