File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff 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 */
7576export 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/**
You can’t perform that action at this time.
0 commit comments