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

✨ Add a generic preset that uses a configuration file #160

Merged
merged 1 commit into from
Jan 5, 2020
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
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')