Skip to content

Commit

Permalink
fix: use whatBump option (#106)
Browse files Browse the repository at this point in the history
* fix: use whatBump opt when provided

* test: ensure commits are passed as expected
  • Loading branch information
davidlj95 authored Nov 11, 2024
1 parent f07f530 commit 09aac9e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
17 changes: 16 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -382,6 +382,21 @@ test('should not bump when whatBump === false', async () => {
}
});

test('should use given whatBump when provided', async () => {
setup();
sh.exec(`git tag 1.0.0`);
add('fix', 'bar');
const whatBump = mock.fn()
{
const options = getOptions({ whatBump });
await runTasks(...options);
assert.ok(whatBump.mock.callCount() > 1)
const commitHeaders = whatBump.mock.calls[0].arguments[0]?.map((commit) => commit.header)
assert.strictEqual(commitHeaders.length, 1)
assert.match(commitHeaders[0], /^fix\(bar\):/)
}
});

// TODO Prepare test and verify results influenced by parserOpts and writerOpts
test.skip('should pass parserOpts and writerOpts', async t => {
setup();
Expand Down

0 comments on commit 09aac9e

Please sign in to comment.