signed-off-by.js 947 B

1234567891011121314151617181920212223
  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.signedOffBy = void 0;
  7. const message_1 = __importDefault(require("@commitlint/message"));
  8. const to_lines_1 = __importDefault(require("@commitlint/to-lines"));
  9. exports.signedOffBy = (parsed, when = 'always', value = '') => {
  10. const lines = to_lines_1.default(parsed.raw).filter((ln) =>
  11. // skip comments
  12. !ln.startsWith('#') &&
  13. // ignore empty lines
  14. Boolean(ln));
  15. const last = lines[lines.length - 1];
  16. const negated = when === 'never';
  17. const hasSignedOffBy = last.startsWith(value);
  18. return [
  19. negated ? !hasSignedOffBy : hasSignedOffBy,
  20. message_1.default(['message', negated ? 'must not' : 'must', 'be signed off']),
  21. ];
  22. };
  23. //# sourceMappingURL=signed-off-by.js.map