Skip to content

Commit

Permalink
fix(bump): propagate the parserOpts from args to conventionalRecommen…
Browse files Browse the repository at this point in the history
…dedBump, fixing an issue with custom headerPatterns (#89)

* chore(bump): also propagate the parserOpts from args to conventionalRecommendedBump

* chore(tests): add the third possible parameter for the bump function to the mocking for tests
  • Loading branch information
jan-mrm authored Aug 22, 2023
1 parent 9ed2207 commit bc685be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function bumpVersion (releaseAs, currentVersion, args) {
path: args.path,
tagPrefix: args.tagPrefix,
lernaPackage: args.lernaPackage
}, function (err, release) {
}, args.parserOpts, function (err, release) {
if (err) return reject(err)
else return resolve(release)
})
Expand Down
6 changes: 3 additions & 3 deletions test/config-files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ function exec () {
*
* Mocks should be unregistered in test cleanup by calling unmock()
*
* bump?: 'major' | 'minor' | 'patch' | Error | (opt, cb) => { cb(err) | cb(null, { releaseType }) }
* bump?: 'major' | 'minor' | 'patch' | Error | (opt, parserOpts, cb) => { cb(err) | cb(null, { releaseType }) }
* changelog?: string | Error | Array<string | Error | (opt) => string | null>
* tags?: string[] | Error
*/
function mock ({ bump, changelog, tags } = {}) {
mockery.enable({ warnOnUnregistered: false, useCleanCache: true })

mockery.registerMock('conventional-recommended-bump', function (opt, cb) {
if (typeof bump === 'function') bump(opt, cb)
mockery.registerMock('conventional-recommended-bump', function (opt, parserOpts, cb) {
if (typeof bump === 'function') bump(opt, parserOpts, cb)
else if (bump instanceof Error) cb(bump)
else cb(null, bump ? { releaseType: bump } : {})
})
Expand Down
8 changes: 4 additions & 4 deletions test/core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getPackageVersion () {
*
* Mocks should be unregistered in test cleanup by calling unmock()
*
* bump?: 'major' | 'minor' | 'patch' | Error | (opt, cb) => { cb(err) | cb(null, { releaseType }) }
* bump?: 'major' | 'minor' | 'patch' | Error | (opt, parserOpts, cb) => { cb(err) | cb(null, { releaseType }) }
* changelog?: string | Error | Array<string | Error | (opt) => string | null>
* execFile?: ({ dryRun, silent }, cmd, cmdArgs) => Promise<string>
* fs?: { [string]: string | Buffer | any }
Expand All @@ -46,8 +46,8 @@ function getPackageVersion () {
function mock ({ bump, changelog, execFile, fs, pkg, tags } = {}) {
mockery.enable({ warnOnUnregistered: false, useCleanCache: true })

mockery.registerMock('conventional-recommended-bump', function (opt, cb) {
if (typeof bump === 'function') bump(opt, cb)
mockery.registerMock('conventional-recommended-bump', function (opt, parserOpts, cb) {
if (typeof bump === 'function') bump(opt, parserOpts, cb)
else if (bump instanceof Error) cb(bump)
else cb(null, bump ? { releaseType: bump } : {})
})
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('cli', function () {

it('creates a prerelease with a new minor version after two prerelease patches', async function () {
let releaseType = 'patch'
const bump = (_, cb) => cb(null, { releaseType })
const bump = (_, __, cb) => cb(null, { releaseType })
mock({
bump,
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
Expand Down
6 changes: 3 additions & 3 deletions test/git.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ function getPackageVersion () {
/**
* Mock external conventional-changelog modules
*
* bump: 'major' | 'minor' | 'patch' | Error | (opt, cb) => { cb(err) | cb(null, { releaseType }) }
* bump: 'major' | 'minor' | 'patch' | Error | (opt, parserOpts, cb) => { cb(err) | cb(null, { releaseType }) }
* changelog?: string | Error | Array<string | Error | (opt) => string | null>
* tags?: string[] | Error
*/
function mock ({ bump, changelog, tags }) {
if (bump === undefined) throw new Error('bump must be defined for mock()')
mockery.enable({ warnOnUnregistered: false, useCleanCache: true })

mockery.registerMock('conventional-recommended-bump', function (opt, cb) {
if (typeof bump === 'function') bump(opt, cb)
mockery.registerMock('conventional-recommended-bump', function (opt, parserOpts, cb) {
if (typeof bump === 'function') bump(opt, parserOpts, cb)
else if (bump instanceof Error) cb(bump)
else cb(null, { releaseType: bump })
})
Expand Down

0 comments on commit bc685be

Please sign in to comment.