UNPKG

ruins

Version:

> [!IMPORTANT] > This is in beta. Not everything is ironed out and some modules might misbehave

13 lines (10 loc) 437 B
/** * Parse conventional commit, returns undefined if not valid, its parts if valid */ export const parseConventionalCommit = (message: string) => { const conventionalCommitRegex = /^(?<type>\w+)(\((?<scope>[^)]+)\))?: (?<description>.+)$/; const match = message.match(conventionalCommitRegex); if (!match || !match.groups) return; const { type, scope, description } = match.groups; return { type, scope, description }; };