feat(parser/file): force quit on non empty conf
This commit is contained in:
parent
868154b440
commit
5abda79a54
|
@ -7,7 +7,8 @@ import (
|
|||
)
|
||||
|
||||
type Conf struct {
|
||||
Name string
|
||||
Name string
|
||||
ForceQuitOnNonEmpty bool
|
||||
}
|
||||
|
||||
type File struct{}
|
||||
|
@ -20,12 +21,16 @@ func (*File) Run(results []stage.ExecutorResult, confAny any) (
|
|||
return nil, true, err
|
||||
}
|
||||
var res []stage.ParserResult
|
||||
forceQuit := false
|
||||
for _, result := range results {
|
||||
content := result.Files[conf.Name]
|
||||
if conf.ForceQuitOnNonEmpty && content != "" {
|
||||
forceQuit = true
|
||||
}
|
||||
if !strings.HasSuffix(content, "\n") {
|
||||
content += "\n"
|
||||
}
|
||||
res = append(res, stage.ParserResult{Score: 0, Comment: content})
|
||||
}
|
||||
return res, false, nil
|
||||
return res, forceQuit, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user