From 72f7232b1958fa08433a7a9a1de4228afce9206a Mon Sep 17 00:00:00 2001 From: jan-mrm <67435696+jan-mrm@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:22:37 +0200 Subject: [PATCH 1/2] fix(bump): also propagate the parserOpts from args to conventionalRecommendedBump --- lib/lifecycles/bump.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index 7758dc6e6..da72199f6 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -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) }) From 5380470ea2c435b62a0ed0fc4319c59d63f980d2 Mon Sep 17 00:00:00 2001 From: jan-mrm <67435696+jan-mrm@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:03:27 +0200 Subject: [PATCH 2/2] fix(tests): add the third possible parameter for the bump function to the mocking for tests --- test/config-files.spec.js | 6 +++--- test/core.spec.js | 8 ++++---- test/git.spec.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/config-files.spec.js b/test/config-files.spec.js index 9e04877c1..8f39693f6 100644 --- a/test/config-files.spec.js +++ b/test/config-files.spec.js @@ -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 | 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 } : {}) }) diff --git a/test/core.spec.js b/test/core.spec.js index a94ac5035..a6dfbf0fe 100644 --- a/test/core.spec.js +++ b/test/core.spec.js @@ -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 | null> * execFile?: ({ dryRun, silent }, cmd, cmdArgs) => Promise * fs?: { [string]: string | Buffer | any } @@ -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 } : {}) }) @@ -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\n' } diff --git a/test/git.spec.js b/test/git.spec.js index 74ee6313e..22b345a04 100644 --- a/test/git.spec.js +++ b/test/git.spec.js @@ -38,7 +38,7 @@ 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 | null> * tags?: string[] | Error */ @@ -46,8 +46,8 @@ 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 }) })