@commitlint/parse 20.2.0 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Parser } from "@commitlint/types";
2
- import { type Commit, type Options } from "conventional-commits-parser";
3
- export declare function parse(message: string, parser?: Parser, parserOpts?: Options): Promise<Commit>;
2
+ import { type Commit, type ParserOptions } from "conventional-commits-parser";
3
+ export declare function parse(message: string, parser?: Parser, parserOpts?: ParserOptions): Promise<Commit>;
4
4
  export default parse;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,6BAA6B,CAAC;AAI9E,wBAAsB,KAAK,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAa,EACrB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAElB,MAAM,6BAA6B,CAAC;AAgBrC,wBAAsB,KAAK,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAsB,EAC9B,UAAU,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,eAAe,KAAK,CAAC"}
package/lib/index.js CHANGED
@@ -1,13 +1,26 @@
1
- import { sync } from "conventional-commits-parser";
1
+ import { CommitParser, } from "conventional-commits-parser";
2
2
  // @ts-expect-error -- no typings
3
3
  import defaultChangelogOpts from "conventional-changelog-angular";
4
- export async function parse(message, parser = sync, parserOpts) {
4
+ const defaultParser = (message, options) => {
5
+ if (message === undefined || message === null) {
6
+ throw new TypeError("Expected a raw commit");
7
+ }
8
+ const parser = new CommitParser(options);
9
+ const result = parser.parse(message);
10
+ result.scope = result.scope ?? null;
11
+ result.subject = result.subject ?? null;
12
+ result.type = result.type ?? null;
13
+ return result;
14
+ };
15
+ export async function parse(message, parser = defaultParser, parserOpts) {
5
16
  const preset = await defaultChangelogOpts();
6
- const defaultOpts = preset.parserOpts;
17
+ const defaultOpts = preset.parser || preset.parserOpts;
18
+ // Support user-provided parser options passed either flat or nested under a 'parser' key
19
+ const userOpts = parserOpts?.parser || parserOpts || {};
7
20
  const opts = {
8
21
  ...defaultOpts,
9
22
  fieldPattern: null,
10
- ...(parserOpts || {}),
23
+ ...userOpts,
11
24
  };
12
25
  const parsed = parser(message, opts);
13
26
  parsed.raw = message;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC9E,iCAAiC;AACjC,OAAO,oBAAoB,MAAM,gCAAgC,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,KAAK,CAC1B,OAAe,EACf,SAAiB,IAAI,EACrB,UAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,MAAM,IAAI,GAAG;QACZ,GAAG,WAAW;QACd,YAAY,EAAE,IAAI;QAClB,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC;KACrB,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,CAAW,CAAC;IAC/C,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC;IACrB,OAA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C/C,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC;IACrB,OAAO,MAAM,CAAC;AACf,CAAC;AAED,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commitlint/parse",
3
3
  "type": "module",
4
- "version": "20.2.0",
4
+ "version": "20.4.0",
5
5
  "description": "Lint your commit messages",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -36,14 +36,13 @@
36
36
  },
37
37
  "license": "MIT",
38
38
  "devDependencies": {
39
- "@commitlint/test": "^20.0.0",
40
- "@commitlint/utils": "^20.0.0",
41
- "@types/conventional-commits-parser": "^5.0.0"
39
+ "@commitlint/test": "^20.4.0",
40
+ "@commitlint/utils": "^20.0.0"
42
41
  },
43
42
  "dependencies": {
44
- "@commitlint/types": "^20.2.0",
45
- "conventional-changelog-angular": "^7.0.0",
46
- "conventional-commits-parser": "^5.0.0"
43
+ "@commitlint/types": "^20.4.0",
44
+ "conventional-changelog-angular": "^8.1.0",
45
+ "conventional-commits-parser": "^6.2.1"
47
46
  },
48
- "gitHead": "ddad9b44d6dd98b983f338bee1ff44dfa9dc1ab1"
47
+ "gitHead": "c68de5e24b010e38eac171f35ba18d31bb1fd3dd"
49
48
  }