Skip to content

Commit

Permalink
✨ Add a generic preset using configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
frinyvonnick committed Jan 4, 2020
1 parent 82d4f53 commit 4886ac2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/gitmoji-changelog-cli/src/presets/generic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const rc = require('rc')

module.exports = () => {
try {
const customConfiguration = rc('gitmoji-changelog')
if (!customConfiguration.configs) throw Error('Configuration not found')

return customConfiguration.project
} catch (e) {
return null
}
}
26 changes: 26 additions & 0 deletions packages/gitmoji-changelog-cli/src/presets/generic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const rc = require('rc')

const loadProjectInfo = require('./generic.js')

describe('getPackageInfo', () => {
it('should extract github repo info from configuration file', async () => {
rc.mockImplementationOnce(() => ({
project: {
name: 'gitmoji-changelog',
version: '0.0.1',
description: 'Gitmoji Changelog CLI',
},
configs: [],
}))

const result = await loadProjectInfo()

expect(result).toEqual({
name: 'gitmoji-changelog',
version: '0.0.1',
description: 'Gitmoji Changelog CLI',
})
})
})

jest.mock('rc')

0 comments on commit 4886ac2

Please sign in to comment.