Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: port parse to typescript (#764)
* refactor: port parse to typescript * refactor: add commit interface to parse return type * refactor: remove replaced dependencies from parse * refactor(parse): add strict options interface * refactor(parse): add strict parser type * test(parse): add empty and no commit message tests
- Loading branch information
Showing
8 changed files
with
165 additions
and
113 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
This file was deleted.
Oops, something went wrong.
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
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,22 @@ | ||
import {isArray, mergeWith} from 'lodash'; | ||
import {Commit, Parser, ParserOptions} from './types'; | ||
|
||
const {sync} = require('conventional-commits-parser'); | ||
const defaultChangelogOpts = require('conventional-changelog-angular'); | ||
|
||
export default parse; | ||
export * from './types'; | ||
|
||
async function parse( | ||
message: string, | ||
parser: Parser = sync, | ||
parserOpts?: ParserOptions | ||
): Promise<Commit> { | ||
const defaultOpts = (await defaultChangelogOpts).parserOpts; | ||
const opts = mergeWith({}, defaultOpts, parserOpts, (objValue, srcValue) => { | ||
if (isArray(objValue)) return srcValue; | ||
}); | ||
const parsed = parser(message, opts) as Commit; | ||
parsed.raw = message; | ||
return parsed; | ||
} |
Oops, something went wrong.