Skip to content

Commit

Permalink
Merge pull request #8 from kf6kjg/fix_542
Browse files Browse the repository at this point in the history
fix: Combining both release-as and prerelease now doesn't break package
  • Loading branch information
TimothyJones authored May 25, 2022
2 parents d2491bc + dc34a9c commit 5ecfa2e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ async function Bump (args, version) {
const release = await bumpVersion(args.releaseAs, version, args)
if (!args.firstRelease) {
const releaseType = getReleaseType(args.prerelease, release.releaseType, version)
newVersion = semver.valid(releaseType) || semver.inc(version, releaseType, args.prerelease)
const releaseTypeAsVersion = releaseType === 'pre' + release.releaseType ? semver.valid(release.releaseType + '-' + args.prerelease + '.0') : semver.valid(releaseType)

newVersion = releaseTypeAsVersion || semver.inc(version, releaseType, args.prerelease)
updateConfigs(args, newVersion)
} else {
checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))
Expand Down
38 changes: 37 additions & 1 deletion test/core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const stdMocks = require('std-mocks')
const cli = require('../command')
const formatCommitMessage = require('../lib/format-commit-message')

require('chai').should()
const should = require('chai').should()

// set by mock()
let standardVersion
Expand Down Expand Up @@ -364,6 +364,42 @@ describe('cli', function () {
await exec('--release-as 200.0.0-amazing')
getPackageVersion().should.equal('200.0.0-amazing')
})

it('releases as 100.0.0 with prerelease amazing', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' },
pkg: {
version: '1.0.0'
}
})
await exec('--release-as 100.0.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.0')
})

it('release 100.0.0 with prerelease amazing bumps build', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
pkg: {
version: '100.0.0-amazing.0'
}
})
await exec('--release-as 100.0.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.1')
})

it('release 100.0.0-amazing.0 with prerelease amazing bumps build', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
pkg: {
version: '100.0.0-amazing.0'
}
})
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.1')
})
})

it('creates a prerelease with a new minor version after two prerelease patches', async function () {
Expand Down

0 comments on commit 5ecfa2e

Please sign in to comment.