UNPKG

1.22 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.bodyCase = void 0;
7const ensure_1 = require("@commitlint/ensure");
8const message_1 = __importDefault(require("@commitlint/message"));
9const negated = (when) => when === 'never';
10const 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};
34exports.bodyCase = bodyCase;
35//# sourceMappingURL=body-case.js.map
\No newline at end of file