@wroud/conventional-commits-parser
Version:
A lightweight parser for conventional commits that supports extracting commit metadata, generating commit messages, and managing commit trailers in TypeScript.
58 lines (39 loc) • 1.93 kB
Markdown
[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]
<!-- [![Install size][size]][size-url] -->
[]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[]: https://img.shields.io/npm/v/@wroud/conventional-commits-parser.svg
[]: https://npmjs.com/package/@wroud/conventional-commits-parser
[]: https://packagephobia.com/badge?p=@wroud/conventional-commits-parser
[]: https://packagephobia.com/result?p=@wroud/conventional-commits-parser
`@wroud/conventional-commits-parser` is a lightweight library designed to parse conventional commit messages. It provides a structured way to extract commit types, scopes, and messages according to the conventional commits specification.
- **Conventional Commits Parsing**: Extract commit types, scopes, and messages.
- **TypeScript**: Written in TypeScript for type safety and modern JavaScript support.
- [Pure ESM package][esm-info-url]
Install via npm:
```sh
npm install @wroud/conventional-commits-parser @wroud/git
```
First, get `IGitCommitInfo` using `getGitCommits` from `@wroud/git`:
```ts
import { getGitCommits } from "@wroud/git";
import { parseConventionalCommit } from "@wroud/conventional-commits-parser";
async function example() {
const commitGenerator = getGitCommits();
for await (const commitInfo of commitGenerator) {
const parsedCommit = parseConventionalCommit(commitInfo);
console.log(parsedCommit);
// Output: { type: 'feat', scope: 'scope', description: 'add new feature' }
}
}
example();
```
All notable changes to this project will be documented in the [CHANGELOG](./CHANGELOG.md) file.
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.