5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 08:06:54 +00:00

Merge pull request #11 from mjhd-devlion/feat/pass-opts

feat: support lint opts
This commit is contained in:
Wagner Santos 2019-11-25 11:49:58 -03:00 committed by GitHub
commit ad1a5cd85d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

16
run.js
View file

@ -86,13 +86,27 @@ function getHistoryCommits(from, to) {
})
}
function getOptsFromConfig(config) {
return {
parserOpts:
config.parserPreset != null && config.parserPreset.parserOpts != null
? config.parserPreset.parserOpts
: {},
plugins: config.plugins != null ? config.plugins : {},
ignores: config.ignores != null ? config.ignores : [],
defaultIgnores:
config.defaultIgnores != null ? config.defaultIgnores : true,
}
}
const showLintResults = async ([from, to]) => {
const commits = await getHistoryCommits(from, to)
const config = existsSync(configPath)
? await load({}, { file: configPath })
: {}
const opts = getOptsFromConfig(config)
const results = await Promise.all(
commits.map(commit => lint(commit, config.rules)),
commits.map(commit => lint(commit, config.rules, opts)),
)
const formattedResults = format(
{ results },