Skip to content

Commit

Permalink
fix(preset-loader): fix handling conventionalcommits preset without c…
Browse files Browse the repository at this point in the history
…onfig object


closes #512
  • Loading branch information
tommywo committed Sep 5, 2019
1 parent 958d243 commit 6425972
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions packages/conventional-changelog-cli/test/test.js
Expand Up @@ -367,6 +367,19 @@ describe('cli', function () {
done()
}))
})
it('--preset "conventionalcommits" should work', function (done) {
writeFileSync('angular', '')
shell.exec('git add --all && git commit -m"fix: fix it!"')
var cp = spawn(cliPath, ['--preset', 'conventionalcommits'], {
stdio: [process.stdin, null, null]
})

cp.stdout
.pipe(concat(function (chunk) {
expect(chunk.toString()).to.include('Bug Fixes')
done()
}))
})

it('--config should work with --preset', function (done) {
var cp = spawn(cliPath, ['--preset', 'angular', '--config', path.join(__dirname, 'fixtures/config.js')], {
Expand Down
5 changes: 3 additions & 2 deletions packages/conventional-changelog-preset-loader/index.js
Expand Up @@ -33,8 +33,9 @@ function presetLoader (requireMethod) {
// rather than returning a promise, presets can return a builder function
// which accepts a config object (allowing for customization) and returns
// a promise.
if (config && !config.then && typeof path === 'object') {
return config(path)
if (config && !config.then) {
const options = typeof path === 'object' ? path : {}
return config(options)
} else {
// require returned a promise that resolves to a config object.
return config
Expand Down

0 comments on commit 6425972

Please sign in to comment.