parseConventionalCommit
Parses a Conventional Commits message into a structured object.
The first line is matched against the regex produced by
buildConventionalCommitRegex(options). The remaining content is split into
a body and an optional trailing footer block (lines matching
Token: value / Token #value, including BREAKING CHANGE: ...).
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message | string | Full commit message (subject + optional body/footer). |
options | ConventionalCommitOptions | Optional constraints forwarded to the regex builder. (optional) |
Returns
Section titled “Returns”ParsedConventionalCommit | null — Parsed commit object, or null when the subject is not conventional.
Examples
Section titled “Examples”Parse a Conventional Commits subject
Section titled “Parse a Conventional Commits subject”Extracts type, scope, breaking flag, and description.
Detect breaking changes from the footer
Section titled “Detect breaking changes from the footer”A BREAKING CHANGE: footer flags the commit as breaking even without the ! marker.
Returns null on a non-conventional message
Section titled “Returns null on a non-conventional message”Non-matching subjects return null rather than throwing.
Related Types
Section titled “Related Types”ConventionalCommitOptions
Section titled “ConventionalCommitOptions”Options shared by buildConventionalCommitRegex, parseConventionalCommit,
and isConventionalCommit to constrain the accepted commit format.
ParsedConventionalCommit
Section titled “ParsedConventionalCommit”Parsed representation of a Conventional Commit message.
