From e87e1cc75ad0ab51e375b7a12f42be86fc83acf7 Mon Sep 17 00:00:00 2001 From: Iryna Makar Date: Thu, 2 Mar 2023 13:25:42 +0100 Subject: [PATCH] fix(parse-commit-messages): do not stop the script when there were no changes and allot to proceed to the plugin code --- src/collect/parse-commit-messages/index.ts | 3 +-- .../parse-commit-messages/spec/index.spec.ts | 17 ++--------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/collect/parse-commit-messages/index.ts b/src/collect/parse-commit-messages/index.ts index 89493c2..8e1386b 100644 --- a/src/collect/parse-commit-messages/index.ts +++ b/src/collect/parse-commit-messages/index.ts @@ -53,8 +53,7 @@ export const parseCommitMessages: Module = (env: Env) => { )} major / ${yellow(counterMinor)} minor / ${green(counterPatch)} patch` ); } else { - log('No relevant commits found, stopping the script'); - process.exit(0); + log('No relevant commits found'); } return { ...env, commitMessages } as Env; diff --git a/src/collect/parse-commit-messages/spec/index.spec.ts b/src/collect/parse-commit-messages/spec/index.spec.ts index 412ef8f..c6413d5 100644 --- a/src/collect/parse-commit-messages/spec/index.spec.ts +++ b/src/collect/parse-commit-messages/spec/index.spec.ts @@ -47,17 +47,11 @@ jest.mock('../add-level', () => ({ addLevel: mockAddLevel })); describe('parse-commit-messages', () => { let parseCommitMessages: Module; - let mockProcessExit: jest.SpyInstance; beforeAll(() => { - mockProcessExit = jest.spyOn(process, 'exit').mockImplementation(); parseCommitMessages = require('../index').parseCommitMessages; }); - afterAll(() => { - mockProcessExit.mockRestore(); - }); - test('creates "parse commit messages" logger', () => { expect(mockLogger).toHaveBeenCalledTimes(1); expect(mockLogger).toHaveBeenCalledWith('parse commit messages'); @@ -133,15 +127,8 @@ describe('parse-commit-messages', () => { }); if (major + minor + patch === 0) { - test('exits the script with no error', () => { - expect(mockProcessExit).toHaveBeenCalledTimes(1); - expect(mockProcessExit).toHaveBeenCalledWith(0); - }); - - test('exits the script with no error', () => { - expect(mockLog).toHaveBeenLastCalledWith( - 'No relevant commits found, stopping the script' - ); + test('add logs', () => { + expect(mockLog).toHaveBeenLastCalledWith('No relevant commits found'); }); } else { test(`logs ${major} major, ${minor} minor and ${patch} patch commits`, () => {