UNPKG

git-release-manager

Version:

A tool to generate release notes from git commit history

27 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createCommitMessageRegex = createCommitMessageRegex; exports.createLinkRegex = createLinkRegex; exports.createMentionRegex = createMentionRegex; function createCommitMessageRegex(commitTypes) { if (!(commitTypes === null || commitTypes === void 0 ? void 0 : commitTypes.length)) return null; const types = commitTypes.flatMap(commitType => commitType.terms); const joinedTypes = types.map(type => type.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'); return new RegExp(`^(${joinedTypes})(\\(.+\\))?[!+~?*]?:\\s.+$`); } function createLinkRegex(linkTypes) { if (!(linkTypes === null || linkTypes === void 0 ? void 0 : linkTypes.length)) return null; const terms = linkTypes.filter(linkType => linkType.terms).flatMap(linkType => linkType.terms || []); const joinedTerms = terms.map(term => term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'); return new RegExp(`(${joinedTerms}):?\\s#?(\\d+)`, 'gi'); } function createMentionRegex(mentionTypes) { if (!(mentionTypes === null || mentionTypes === void 0 ? void 0 : mentionTypes.length)) return null; const terms = mentionTypes.flatMap(mentionType => mentionType.terms); const joinedTerms = terms.map(term => term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'); return new RegExp(`(?:${joinedTerms}):\\s(.+)\\s<(.+)>`, 'gi'); } //# sourceMappingURL=regexHandlers.js.map