signed-off-by.js 990 B

123456789101112131415161718192021222324
  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. const signedOffBy = (parsed, when = 'always', value = '') => {
  10. const lines = (0, 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. (0, message_1.default)(['message', negated ? 'must not' : 'must', 'be signed off']),
  21. ];
  22. };
  23. exports.signedOffBy = signedOffBy;
  24. //# sourceMappingURL=signed-off-by.js.map