diff --git a/README.md b/README.md index 0b872811..1fdfb145 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ With this example: | `parserOpts` | Additional [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#conventionalcommitsparseroptions) options that will extends the ones loaded by `preset` or `config`. This is convenient to use a [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset with some customizations without having to create a new module. | - | | `releaseRules` | An external module, a path to a module or an `Array` of rules. See [`releaseRules`](#releaserules). | See [`releaseRules`](#releaserules) | | `presetConfig` | Additional configuration passed to the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset. Used for example with [conventional-changelog-conventionalcommits](https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/master/versions/2.0.0/README.md). | - | +| `useDefaultReleaseRules` | Boolean to control whether or not to use the default rules. See [default rules](lib/default-release-rules.js). | `false` | **Notes**: in order to use a `preset` it must be installed (for example to use the [eslint preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint) you must install it with `npm install conventional-changelog-eslint -D`) @@ -182,3 +183,23 @@ module.exports = [ {type: 'refactor', release: 'patch'}, ]; ``` +##### Ignoring default rules + +If you want to sepcify your own custom commit style you can set the `useDefaultReleaseRules` property to `false`. And the [default rules](lib/default-release-rules.js) won't be used: +```json +{ + "plugins": [ + ["@semantic-release/commit-analyzer", { + "useDefaultReleaseRules": false, + "releaseRules": [ + {"tag": "Major", "release": "major"}, + {"tag": "Minor", "release": "minor"}, + {"tag": "Patch", "release": "patch"} + ] + }], + "@semantic-release/release-notes-generator" + ] +} +``` + +**Notes**: The value of the `preset` property will not have any effect when ignoring the default rules. \ No newline at end of file diff --git a/index.js b/index.js index 65d4f298..287b6eda 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ const DEFAULT_RELEASE_RULES = require('./lib/default-release-rules'); * @param {String} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint') * @param {String} pluginConfig.config Requierable npm package with a custom conventional-changelog preset * @param {String|Array} pluginConfig.releaseRules A `String` to load an external module or an `Array` of rules. + * @param {Boolean} pluginConfig.useDefaultReleaseRules A `Boolean` to control whether to use the default rules or not. * @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`. * @param {Object} context The semantic-release context. * @param {Array} context.commits The commits to analyze. @@ -26,6 +27,7 @@ const DEFAULT_RELEASE_RULES = require('./lib/default-release-rules'); async function analyzeCommits(pluginConfig, context) { const {commits, logger} = context; const releaseRules = loadReleaseRules(pluginConfig, context); + const {useDefaultReleaseRules = true} = pluginConfig; const config = await loadParserConfig(pluginConfig, context); let releaseType = null; @@ -50,8 +52,8 @@ async function analyzeCommits(pluginConfig, context) { commitReleaseType = analyzeCommit(releaseRules, commit); } - // If no custom releaseRules or none matched the commit, try with default releaseRules - if (isUndefined(commitReleaseType)) { + // If default releaseRules should be used, and no custom releaseRules, or none matched the commit: try with default releaseRules + if (useDefaultReleaseRules && isUndefined(commitReleaseType)) { debug('Analyzing with default rules'); commitReleaseType = analyzeCommit(DEFAULT_RELEASE_RULES, commit); }