2020-03-10 13:29:44 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2020-03-10 13:29:44 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2020-05-08 17:51:29 -04:00
|
|
|
|
|
|
|
import {assertNoErrors, getConfig, NgDevConfig} from '../utils/config';
|
|
|
|
|
2020-03-10 13:29:44 -04:00
|
|
|
export interface CommitMessageConfig {
|
|
|
|
maxLineLength: number;
|
|
|
|
minBodyLength: number;
|
2020-06-25 20:39:55 -04:00
|
|
|
minBodyLengthTypeExcludes?: string[];
|
2020-03-10 13:29:44 -04:00
|
|
|
types: string[];
|
|
|
|
scopes: string[];
|
2020-03-20 15:24:12 -04:00
|
|
|
}
|
2020-05-08 17:51:29 -04:00
|
|
|
|
|
|
|
/** Retrieve and validate the config as `CommitMessageConfig`. */
|
|
|
|
export function getCommitMessageConfig() {
|
|
|
|
// List of errors encountered validating the config.
|
|
|
|
const errors: string[] = [];
|
2020-06-25 20:39:55 -04:00
|
|
|
// The non-validated config object.
|
2020-05-08 17:51:29 -04:00
|
|
|
const config: Partial<NgDevConfig<{commitMessage: CommitMessageConfig}>> = getConfig();
|
|
|
|
|
|
|
|
if (config.commitMessage === undefined) {
|
|
|
|
errors.push(`No configuration defined for "commitMessage"`);
|
|
|
|
}
|
|
|
|
|
|
|
|
assertNoErrors(errors);
|
|
|
|
return config as Required<typeof config>;
|
|
|
|
}
|