From 13ed283182c71ce7b236172989b6db5557edc70f Mon Sep 17 00:00:00 2001 From: David LJ Date: Sat, 9 Nov 2024 18:55:30 +0100 Subject: [PATCH] fix: use whatBump opt when provided --- index.js | 2 ++ test.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 844fb65..9d66558 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,8 @@ class ConventionalChangelog extends Plugin { async function getWhatBump() { if (options.whatBump === false) { return () => ({ releaseType: null }); + } else if (typeof options.whatBump === 'function') { + return options.whatBump; } const bumperPreset = await bumper.preset; diff --git a/test.js b/test.js index 665142a..0888077 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -import test from 'node:test'; +import {mock, test} from 'node:test'; import { strict as assert } from 'assert'; import fs from 'fs'; import path from 'path'; @@ -382,6 +382,16 @@ test('should not bump when whatBump === false', async () => { } }); +test('should use given whatBump when provided', async () => { + setup(); + const whatBump = mock.fn() + { + const options = getOptions({ whatBump }); + await runTasks(...options); + assert.ok(whatBump.mock.callCount() > 1) + } +}); + // TODO Prepare test and verify results influenced by parserOpts and writerOpts test.skip('should pass parserOpts and writerOpts', async t => { setup();