Skip to content

Commit e56caca

Browse files
committed
feat: add defaultToPatchRelease option
1 parent c886405 commit e56caca

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
>
33
> This is a fork of [semantic-release's
44
> commit-analyzer](https://github.com/semantic-release/commit-analyzer) that has
5-
> been modified to include a `disableDefaultReleaseRules` option which can be
6-
> used like this:
5+
> been modified to include `disableDefaultReleaseRules` and
6+
> `defaultToPatchRelease` options which can be used like this:
77
>
88
> ```json
99
> {
@@ -18,13 +18,14 @@
1818
> { "type": "style", "release": "patch" }
1919
> ],
2020
> "disableDefaultReleaseRules": true,
21+
> "defaultToPatchRelease": true,
2122
> }
2223
> ]
2324
> ]
2425
> }
2526
> ```
2627
>
27-
> This is heavily inspired by this pull-request and will not be needed once it is merged:
28+
> This is heavily inspired by this pull-request:
2829
>
2930
> https://github.com/semantic-release/commit-analyzer/pull/211
3031
>

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const debug = debugFactory("semantic-release:commit-analyzer");
1919
* @param {String} pluginConfig.config Requireable npm package with a custom conventional-changelog preset
2020
* @param {String|Array} pluginConfig.releaseRules A `String` to load an external module or an `Array` of rules.
2121
* @param {Boolean} pluginConfig.disableDefaultReleaseRules A `Boolean` that will prevent the default release rules to be used if a rule is not matched.
22+
* @param {Boolean} pluginConfig.defaultToPatchRelease A `Boolean` to return a patch release when no release type is determined.
2223
* @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
2324
* @param {Object} context The semantic-release context.
2425
* @param {Array<Object>} context.commits The commits to analyze.
@@ -86,5 +87,10 @@ export async function analyzeCommits(pluginConfig, context) {
8687

8788
logger.log("Analysis of %s commits complete: %s release", commits.length, releaseType || "no");
8889

90+
if (releaseType === null && pluginConfig.defaultToPatchRelease === true) {
91+
logger.log("No release type determined, defaulting to patch release");
92+
return "patch";
93+
}
94+
8995
return releaseType;
9096
}

0 commit comments

Comments
 (0)