Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use whatBump option #106

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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