From 30b5cb7d3b75fb1991db675f187bed1faeff9783 Mon Sep 17 00:00:00 2001 From: LukasFillaBS Date: Wed, 5 Mar 2025 17:32:17 +0100 Subject: [PATCH 1/2] fix: enable commiting with confirmCommit question skipped --- __tests__/cz-customizable.test.js | 23 +++++++++++++++++++++++ index.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/__tests__/cz-customizable.test.js b/__tests__/cz-customizable.test.js index 43b5f2b..ad5314d 100644 --- a/__tests__/cz-customizable.test.js +++ b/__tests__/cz-customizable.test.js @@ -401,4 +401,27 @@ describe('cz-customizable', () => { czModule.prompter(mockCz, commit); expect(commit).toHaveBeenCalledWith('feat(myScope): [TICKET-1234] create a new cool feature'); }); + + it('should call commit() function when confirmCommit message is skipped and no confirmCommit answer is present', () => { + readConfigFile.mockReturnValue({ + types: [{ value: 'feat', name: 'feat: my feat' }], + scopes: [{ name: 'myScope' }], + skipQuestions: ['confirmCommit'], + scopeOverrides: { + fix: [{ name: 'fixOverride' }], + }, + allowCustomScopes: true, + allowBreakingChanges: ['feat'], + usePreparedCommit: true, + }); + + const answers = { + type: 'feat', + subject: 'create a new cool feature', + }; + + const mockCz = getMockedCz(answers); + czModule.prompter(mockCz, commit); + expect(commit).toHaveBeenCalledWith('feat: create a new cool feature'); + }); }); diff --git a/index.js b/index.js index 026b039..377c0d7 100755 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ module.exports = { }); } }); - } else if (answers.confirmCommit === 'yes') { + } else if (answers.confirmCommit === 'yes' || config.skipQuestions.includes('confirmCommit')) { commit(buildCommit(answers, config)); } else { log.info('Commit has been canceled.'); From 1a91041bf86d074e98ff2457c785865ea3ebe0e4 Mon Sep 17 00:00:00 2001 From: LukasFillaBS Date: Wed, 5 Mar 2025 17:43:16 +0100 Subject: [PATCH 2/2] fix: use skip questions prop or default --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 377c0d7..7bbbb92 100755 --- a/index.js +++ b/index.js @@ -18,6 +18,8 @@ module.exports = { const questions = require('./lib/questions').getQuestions(config, cz); + const skipQuestions = config.skipQuestions || []; + cz.prompt(questions).then((answers) => { if (answers.confirmCommit === 'edit') { temp.open(null, (err, info) => { @@ -38,7 +40,7 @@ module.exports = { }); } }); - } else if (answers.confirmCommit === 'yes' || config.skipQuestions.includes('confirmCommit')) { + } else if (answers.confirmCommit === 'yes' || skipQuestions.includes('confirmCommit')) { commit(buildCommit(answers, config)); } else { log.info('Commit has been canceled.');