Skip to content

Commit

Permalink
Merge pull request #39 from leonardoanalista/feature/exit-zero-when-n…
Browse files Browse the repository at this point in the history
…ot-on-master-branch

feat(process): when not on master branch, exit with 0 instead of 1
  • Loading branch information
uglow authored Apr 18, 2017
2 parents d1041c0 + 7a75dce commit 2c6682c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions spec/system.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,18 @@ describe('corp-semantic-release', function() {
expect(out).to.include('Release is not necessary at this point');
});

it('should run if branch is master', function() {
it('should only run if branch is master', function() {
commitWithMessage('feat(accounts): commit 1');
shell.exec('git checkout -b other-branch');

const out = semanticRelease(`-v -d`);
const out = semanticRelease(`-v -d --post-success "echo foo"`);

expect(out).not.to.include('Skipping post-success command');
expect(out).to.include('You can only release from the master branch. Use option --branch to specify branch name.');

shell.exec('git checkout master');
const outMaster = semanticRelease(`-v -d`);
const outMaster = semanticRelease(`-v -d --post-success "echo foo"`);
expect(outMaster).to.include('Skipping post-success command');
expect(outMaster).to.include('>>> Your release branch is: master');
});

Expand Down
4 changes: 2 additions & 2 deletions spec/validateBranch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('validateBranch', () => {

afterEach(() => revert()); // revert the mocking of anything

it('should show a message if the current branch is not the release branch and exit', () => {
it('should show a message if the current branch is not the release branch and exit with 0', () => {
let exitCode;
revert = validateBranch.__set__({
shell: {
Expand All @@ -26,7 +26,7 @@ describe('validateBranch', () => {
});

expect(output[0]).to.include(`You can only release from the bar branch. Use option --branch to specify branch name.`);
expect(exitCode).to.equal(1);
expect(exitCode).to.equal(0);
});


Expand Down
2 changes: 1 addition & 1 deletion src/lib/validateBranch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function validateBranch(branch) {

if (branch !== currentBranch) {
log.error(`You can only release from the ${branch} branch. Use option --branch to specify branch name.`);
shell.exit(1);
shell.exit(0);
} else {
log.info(`>>> Your release branch is: ${branch}`);
}
Expand Down

0 comments on commit 2c6682c

Please sign in to comment.