@commitlint/parse
Advanced tools
+2
-2
| import type { Parser } from "@commitlint/types"; | ||
| import { type Commit, type Options } from "conventional-commits-parser"; | ||
| export declare function parse(message: string, parser?: Parser, parserOpts?: Options): Promise<Commit>; | ||
| import { type Commit, type ParserOptions } from "conventional-commits-parser"; | ||
| export declare function parse(message: string, parser?: Parser, parserOpts?: ParserOptions): Promise<Commit>; | ||
| export default parse; | ||
| //# sourceMappingURL=index.d.ts.map |
+17
-4
@@ -1,11 +0,24 @@ | ||
| import { sync } from "conventional-commits-parser"; | ||
| import { CommitParser, } from "conventional-commits-parser"; | ||
| // @ts-expect-error -- no typings | ||
| import defaultChangelogOpts from "conventional-changelog-angular"; | ||
| export async function parse(message, parser = sync, parserOpts) { | ||
| const defaultParser = (message, options) => { | ||
| if (message === undefined || message === null) { | ||
| throw new TypeError("Expected a raw commit"); | ||
| } | ||
| const parser = new CommitParser(options); | ||
| const result = parser.parse(message); | ||
| result.scope = result.scope ?? null; | ||
| result.subject = result.subject ?? null; | ||
| result.type = result.type ?? null; | ||
| return result; | ||
| }; | ||
| export async function parse(message, parser = defaultParser, parserOpts) { | ||
| const preset = await defaultChangelogOpts(); | ||
| const defaultOpts = preset.parserOpts; | ||
| const defaultOpts = preset.parser || preset.parserOpts; | ||
| // Support user-provided parser options passed either flat or nested under a 'parser' key | ||
| const userOpts = parserOpts?.parser || parserOpts || {}; | ||
| const opts = { | ||
| ...defaultOpts, | ||
| fieldPattern: null, | ||
| ...(parserOpts || {}), | ||
| ...userOpts, | ||
| }; | ||
@@ -12,0 +25,0 @@ const parsed = parser(message, opts); |
+7
-8
| { | ||
| "name": "@commitlint/parse", | ||
| "type": "module", | ||
| "version": "20.3.1", | ||
| "version": "20.4.0", | ||
| "description": "Lint your commit messages", | ||
@@ -39,12 +39,11 @@ "main": "lib/index.js", | ||
| "devDependencies": { | ||
| "@commitlint/test": "^20.0.0", | ||
| "@commitlint/utils": "^20.0.0", | ||
| "@types/conventional-commits-parser": "^5.0.0" | ||
| "@commitlint/test": "^20.4.0", | ||
| "@commitlint/utils": "^20.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "@commitlint/types": "^20.3.1", | ||
| "conventional-changelog-angular": "^7.0.0", | ||
| "conventional-commits-parser": "^5.0.0" | ||
| "@commitlint/types": "^20.4.0", | ||
| "conventional-changelog-angular": "^8.1.0", | ||
| "conventional-commits-parser": "^6.2.1" | ||
| }, | ||
| "gitHead": "be3a280aeadef5afa8ec83dbbe794ab2f72b9c3a" | ||
| "gitHead": "c68de5e24b010e38eac171f35ba18d31bb1fd3dd" | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5699
23.38%2
-33.33%33
65%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated