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.trailerExists = void 0;
|
7 | const execa_1 = __importDefault(require("execa"));
|
8 | const message_1 = __importDefault(require("@commitlint/message"));
|
9 | const to_lines_1 = __importDefault(require("@commitlint/to-lines"));
|
10 | const trailerExists = (parsed, when = 'always', value = '') => {
|
11 | const trailers = execa_1.default.sync('git', ['interpret-trailers', '--parse'], {
|
12 | input: parsed.raw,
|
13 | }).stdout;
|
14 | const matches = to_lines_1.default(trailers).filter((ln) => ln.startsWith(value)).length;
|
15 | const negated = when === 'never';
|
16 | const hasTrailer = matches > 0;
|
17 | return [
|
18 | negated ? !hasTrailer : hasTrailer,
|
19 | message_1.default([
|
20 | 'message',
|
21 | negated ? 'must not' : 'must',
|
22 | 'have `' + value + '` trailer',
|
23 | ]),
|
24 | ];
|
25 | };
|
26 | exports.trailerExists = trailerExists;
|
27 |
|
\ | No newline at end of file |