Skip to content

Commit

Permalink
fix(parse-commit-messages): do not stop the script when there were no…
Browse files Browse the repository at this point in the history
… changes and allot to proceed to the plugin code
  • Loading branch information
Iryna Makar committed Mar 2, 2023
1 parent 8509501 commit e87e1cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/collect/parse-commit-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 2 additions & 15 deletions src/collect/parse-commit-messages/spec/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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`, () => {
Expand Down

0 comments on commit e87e1cc

Please sign in to comment.