mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 08:06:54 +00:00
feat: support opts for lint
This commit is contained in:
parent
dbcd202509
commit
c1cb555db5
1 changed files with 15 additions and 1 deletions
16
run.js
16
run.js
|
|
@ -60,13 +60,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 },
|
||||
|
|
|
|||
Loading…
Reference in a new issue