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

fix(scope): Allow no scope in the commit message when validate is set to true. #69

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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