8000 refactor: update prepareCommitMsg.ts · MichaelCurrin/auto-commit-msg@3fdb9d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fdb9d3

Browse files
committed
refactor: update prepareCommitMsg.ts
1 parent 8e17641 commit 3fdb9d3

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/prepareCommitMsg.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,28 @@ export function _msgOne(line: string) {
6565
* Get single Conventional Commit type prefix from multiple items.
6666
*
6767
* @returns Inferred overall prefix type.
68-
* - The first item if they are equal,
68+
* - Unknown if zero items - not likely in real life but covered anyway.
69+
* - The first item if they are equal.
6970
* - Use unknown if they are different.
7071
* - If at least one item is build dependencies even if the others are
7172
* different, then use that. This covers the case where `package.json` may
7273
* have non-deps changes, but the `package-lock.json` is enough to want to
7374
* use the deps scope.
7475
*/
7576
export function _collapse(types: CONVENTIONAL_TYPE[]) {
77+
let result = CONVENTIONAL_TYPE.UNKNOWN;
78+
7679
if (!types.length) {
77-
return CONVENTIONAL_TYPE.UNKNOWN;
80+
return result;
7881
}
7982

8083
if (equal(types)) {
81-
return types[0];
82-
}
83-
84-
if (types.includes(CONVENTIONAL_TYPE.BUILD_DEPENDENCIES)) {
85-
return CONVENTIONAL_TYPE.BUILD_DEPENDENCIES;
84+
result = types[0];
85+
} else if (types.includes(CONVENTIONAL_TYPE.BUILD_DEPENDENCIES)) {
86+
result = CONVENTIONAL_TYPE.BUILD_DEPENDENCIES;
8687
}
8788

88-
return CONVENTIONAL_TYPE.UNKNOWN;
89+
return result;
8990
}
9091

9192
/**

0 commit comments

Comments
 (0)
0