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