Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
fix(scope): Allow no scope in the commit message when validate is set…
Browse files Browse the repository at this point in the history
… to true. (#69)
  • Loading branch information
yeelan0319 authored and Kent C. Dodds committed Mar 8, 2017
1 parent b737246 commit 7a580ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/validateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ function validateScope(isValid, scope) {
error('a scope is required !');
isValid = false;
}
// If scope is not provided, we ignore the rest of the testing and do early
// return here.
if (scopes.length === 0) {
return isValid;
}
if (isValid && multipleScopesAllowed) {
scopes.forEach(validateIndividualScope);
}
Expand Down
13 changes: 13 additions & 0 deletions test/validateMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ describe('validate-commit-msg.js', function() {
m.config.scope = undefined;
});

it('should allow no scope when only validate is set to true', function() {
var msg = 'chore: Publish';

m.config.scope = {
validate: true
};

expect(m.validateMessage(msg)).to.equal(VALID);
expect(logs).to.deep.equal([]);

m.config.scope = undefined;
});

it('should allow empty scope', function() {
expect(m.validateMessage('fix: blablabla')).to.equal(VALID);
expect(errors).to.deep.equal([]);
Expand Down

0 comments on commit 7a580ce

Please sign in to comment.