Skip to content

Commit

Permalink
Merge pull request #115 from xing/fix-parse-commit-messages
Browse files Browse the repository at this point in the history
fix(parse-commit-messages):  allow to run the script when the were no changes and proceed with the plugin code
  • Loading branch information
irmkr authored Mar 2, 2023
2 parents 64ea1d4 + e87e1cc commit 1576ba2
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 1576ba2

Please sign in to comment.