mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 16:06:56 +00:00
Merge pull request #11 from mjhd-devlion/feat/pass-opts
feat: support lint opts
This commit is contained in:
commit
ad1a5cd85d
1 changed files with 15 additions and 1 deletions
16
run.js
16
run.js
|
|
@ -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 showLintResults = async ([from, to]) => {
|
||||||
const commits = await getHistoryCommits(from, to)
|
const commits = await getHistoryCommits(from, to)
|
||||||
const config = existsSync(configPath)
|
const config = existsSync(configPath)
|
||||||
? await load({}, { file: configPath })
|
? await load({}, { file: configPath })
|
||||||
: {}
|
: {}
|
||||||
|
const opts = getOptsFromConfig(config)
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
commits.map(commit => lint(commit, config.rules)),
|
commits.map(commit => lint(commit, config.rules, opts)),
|
||||||
)
|
)
|
||||||
const formattedResults = format(
|
const formattedResults = format(
|
||||||
{ results },
|
{ results },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue