diff --git a/goldsmith.go b/goldsmith.go index cbd8456..1bc4666 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -189,23 +189,26 @@ func (gs *goldsmith) chain(s *stage, p Plugin) { } } - if proc, ok := p.(Processor); ok { - var wg sync.WaitGroup - for file := range s.input { + accept, _ := p.(Accepter) + proc, _ := p.(Processor) + + var wg sync.WaitGroup + for file := range s.input { + if file.Err != nil || proc == nil || (accept != nil && !accept.Accept(file)) { + s.output <- file + } else { + wg.Add(1) go func(f *File) { defer wg.Done() if proc.Process(s, f) { s.output <- f + } else { + gs.decFiles() } }(file) } - - wg.Wait() - } else { - for file := range s.input { - s.output <- file - } } + wg.Wait() if fin, ok := p.(Finalizer); ok { s.err = fin.Finalize(s) diff --git a/types.go b/types.go index 3d7b6a6..38f20d5 100644 --- a/types.go +++ b/types.go @@ -59,6 +59,10 @@ type Context interface { type Plugin interface{} +type Accepter interface { + Accept(file *File) bool +} + type Initializer interface { Initialize(ctx Context) error }