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

Ensure version is valid before passing it to semver #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
node_modules
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ConventionalChangelog extends Plugin {
skipUnstable: true
});

const lastStableTag = tags.length > 0 ? tags[0] : null;
const lastStableTag = tags.length > 0 ? tags[0].replace(options.tagPrefix, '') : null;

if (
lastStableTag &&
Expand Down
28 changes: 28 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,34 @@ test('should follow conventional commit strategy with prereleaase', async t => {
assert.equal(version4, '2.0.0-alpha.1');
});

test.only('should follow conventional commit strategy with prereleaase and custom prefix', async t => {
setup();
const prefix = 'scope/';
sh.exec(`git tag ${prefix}v1.2.1`);
add('feat', 'baz');

const [config, container] = getOptions({ preset: { name: 'conventionalcommits' } }, { commit: true, tag: true });
config.preRelease = 'alpha';
config.git.tagName = `${prefix}v${'${version}'}`;
const { version: version1 } = await runTasks(config, container);
assert.equal(version1, '1.3.0-alpha.0');

add('fix', 'buz');

const { version: version2 } = await runTasks(config, container);
assert.equal(version2, '1.3.0-alpha.1');

add('feat', 'biz', { breaking: true });

const { version: version3 } = await runTasks(config, container);
assert.equal(version3, '2.0.0-alpha.0');

add('fix', 'boz');

const { version: version4 } = await runTasks(config, container);
assert.equal(version4, '2.0.0-alpha.1');
});

test('should use provided pre-release id (pre-release continuation)', async t => {
setup();
sh.exec(`git tag 1.0.1-alpha.0`);
Expand Down