1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.bodyCase = void 0;
|
7 | const ensure_1 = require("@commitlint/ensure");
|
8 | const message_1 = __importDefault(require("@commitlint/message"));
|
9 | const negated = (when) => when === 'never';
|
10 | const bodyCase = (parsed, when = 'always', value = []) => {
|
11 | const { body } = parsed;
|
12 | if (!body) {
|
13 | return [true];
|
14 | }
|
15 | const checks = (Array.isArray(value) ? value : [value]).map((check) => {
|
16 | if (typeof check === 'string') {
|
17 | return {
|
18 | when: 'always',
|
19 | case: check,
|
20 | };
|
21 | }
|
22 | return check;
|
23 | });
|
24 | const result = checks.some((check) => {
|
25 | const r = (0, ensure_1.case)(body, check.case);
|
26 | return negated(check.when) ? !r : r;
|
27 | });
|
28 | const list = checks.map((c) => c.case).join(', ');
|
29 | return [
|
30 | negated(when) ? !result : result,
|
31 | (0, message_1.default)([`body must`, negated(when) ? `not` : null, `be ${list}`]),
|
32 | ];
|
33 | };
|
34 | exports.bodyCase = bodyCase;
|
35 |
|
\ | No newline at end of file |