diff --git a/README.md b/README.md index 9b51c8b..f6eea00 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,17 @@ for the configuration object to pass as `preset`. - This option will be passed as the first argument to [`bumper.bump`](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-recommended-bump/README.md#api) - [Type definition for `whatBump` → look for `Preset['whatBump']`](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-recommended-bump/src/types.ts) +- Use the `false` Boolean value to skip releasing a new version. + +```json +{ + "plugins": { + "@release-it/conventional-changelog": { + "whatBump": false + } + } +} +``` ### `ignoreRecommendedBump` diff --git a/index.js b/index.js index 21464b5..149f46f 100644 --- a/index.js +++ b/index.js @@ -39,22 +39,30 @@ class ConventionalChangelog extends Plugin { try { const bumper = new Bumper(); - if (options.preset) bumper.loadPreset(options.preset); + if (options.preset) await bumper.loadPreset(options.preset).preset; if (options.tagOpts) bumper.tag(options.tagOpts); if (options.commitsOpts) bumper.commits(options.commitsOpts, options.parserOpts); - const result = await bumper.bump(options.whatBump); + async function getWhatBump() { + if (options.whatBump === false) { + return () => ({ releaseType: null }); + } else { + const bumperPreset = await bumper.preset; + + if (bumperPreset === null) return () => ({ releaseType: null }); + + return bumperPreset.whatBump || bumperPreset.recommendedBumpOpts.whatBump; + } + } + + const result = await bumper.bump(await getWhatBump()); this.debug({ result }); let { releaseType } = result; - if (releaseType == undefined) { - return; - } - if (increment) { this.log.warn(`The recommended bump is "${releaseType}", but is overridden with "${increment}".`); releaseType = increment; diff --git a/test.js b/test.js index de2ca83..665142a 100644 --- a/test.js +++ b/test.js @@ -370,6 +370,18 @@ test('should not bump when recommended bump returns null', async () => { } }); +test('should not bump when whatBump === false', async () => { + setup(); + sh.exec(`git tag 1.0.0`); + add('fix', 'bar'); + add('feat', 'baz'); + { + const options = getOptions({ whatBump: false }); + const { version } = await runTasks(...options); + assert.equal(version, undefined); + } +}); + // TODO Prepare test and verify results influenced by parserOpts and writerOpts test.skip('should pass parserOpts and writerOpts', async t => { setup();