Skip to content

Commit 09aac9e

Browse files
authoredNov 11, 2024··
fix: use whatBump option (#106)
* fix: use whatBump opt when provided * test: ensure commits are passed as expected
1 parent f07f530 commit 09aac9e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
 

‎index.js

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class ConventionalChangelog extends Plugin {
4848
async function getWhatBump() {
4949
if (options.whatBump === false) {
5050
return () => ({ releaseType: null });
51+
} else if (typeof options.whatBump === 'function') {
52+
return options.whatBump;
5153
}
5254
const bumperPreset = await bumper.preset;
5355

‎test.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import {mock, test} from 'node:test';
22
import { strict as assert } from 'assert';
33
import fs from 'fs';
44
import path from 'path';
@@ -382,6 +382,21 @@ test('should not bump when whatBump === false', async () => {
382382
}
383383
});
384384

385+
test('should use given whatBump when provided', async () => {
386+
setup();
387+
sh.exec(`git tag 1.0.0`);
388+
add('fix', 'bar');
389+
const whatBump = mock.fn()
390+
{
391+
const options = getOptions({ whatBump });
392+
await runTasks(...options);
393+
assert.ok(whatBump.mock.callCount() > 1)
394+
const commitHeaders = whatBump.mock.calls[0].arguments[0]?.map((commit) => commit.header)
395+
assert.strictEqual(commitHeaders.length, 1)
396+
assert.match(commitHeaders[0], /^fix\(bar\):/)
397+
}
398+
});
399+
385400
// TODO Prepare test and verify results influenced by parserOpts and writerOpts
386401
test.skip('should pass parserOpts and writerOpts', async t => {
387402
setup();

0 commit comments

Comments
 (0)
Please sign in to comment.