Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conventionalcommits): allow the scope to be omitted #708

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/conventional-changelog-conventionalcommits/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,30 @@ describe('conventionalcommits.org preset', function () {
}))
})

it('should allow omit the scope', function (done) {
preparing(1)
conventionalChangelogCore({
config: require('../')({
types: [
{ type: 'chore', scope: 'deps', section: 'Dependencies', omitScope: true }
]
})
})
.on('error', function (err) {
done(err)
})
.pipe(through(function (chunk) {
chunk = chunk.toString()

expect(chunk).to.include('### Dependencies')
expect(chunk).to.include('upgrade example from 1 to 2')

expect(chunk).to.not.include('**deps:** upgrade example from 1 to 2')
expect(chunk).to.not.include('release 0.0.0')
done()
}))
})

it('should properly format external repository issues', function (done) {
preparing(1)
conventionalChangelogCore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ function getWriterOpts (config) {
if (discard && (entry === undefined ||
entry.hidden)) return

if (entry) commit.type = entry.section
if (entry) {
commit.type = entry.section
if (entry.omitScope) {
commit.scope = ''
}
}

if (commit.scope === '*') {
commit.scope = ''
Expand Down