2020-03-10 13:29:44 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
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[] = [];
|
|
|
|
// The unvalidated config object.
|
|
|
|
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>;
|
|
|
|
}
|