update filter interface

This commit is contained in:
Alex Yatskov 2019-04-02 19:01:36 -07:00
parent 966201a95f
commit bf1f01b9bf
3 changed files with 16 additions and 2 deletions

View File

@ -94,7 +94,7 @@ func (context *Context) step() {
} }
for _, fileFilter := range fileFilters { for _, fileFilter := range fileFilters {
if accept, err = fileFilter.Accept(context, inputFile); err != nil { if accept, err = fileFilter.Accept(inputFile); err != nil {
context.goldsmith.fault(fileFilter.Name(), inputFile, err) context.goldsmith.fault(fileFilter.Name(), inputFile, err)
return return
} }

View File

@ -82,7 +82,20 @@ func (goldsmith *Goldsmith) End(targetDir string) []error {
} }
context := goldsmith.contexts[len(goldsmith.contexts)-1] context := goldsmith.contexts[len(goldsmith.contexts)-1]
export:
for file := range context.outputFiles { for file := range context.outputFiles {
for _, fileFilter := range goldsmith.fileFilters {
accept, err := fileFilter.Accept(file)
if err != nil {
goldsmith.fault(fileFilter.Name(), file, err)
continue export
}
if !accept {
continue export
}
}
goldsmith.exportFile(file) goldsmith.exportFile(file)
} }
@ -103,6 +116,7 @@ func (goldsmith *Goldsmith) storeFile(context *Context, outputFile *File, inputF
if goldsmith.fileCache != nil { if goldsmith.fileCache != nil {
goldsmith.fileCache.storeFile(context, outputFile, inputFiles) goldsmith.fileCache.storeFile(context, outputFile, inputFiles)
} }
} }
func (goldsmith *Goldsmith) removeUnreferencedFiles() { func (goldsmith *Goldsmith) removeUnreferencedFiles() {

View File

@ -18,7 +18,7 @@ type Component interface {
type Filter interface { type Filter interface {
Component Component
Accept(context *Context, file *File) (bool, error) Accept(file *File) (bool, error)
} }
type Plugin interface { type Plugin interface {