-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add a generic preset using configuration file
- Loading branch information
1 parent
82d4f53
commit 4886ac2
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
packages/gitmoji-changelog-cli/src/presets/generic.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |