From 14c9c2065f398d348bcee4e3cbca02d723f3c8f7 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 25 Apr 2021 09:29:53 -0700 Subject: [PATCH] Bugfixes --- goldsmith.go | 6 ++++++ saver.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/goldsmith.go b/goldsmith.go index a6cbd70..08aed19 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -84,14 +84,20 @@ func (goldsmith *Goldsmith) FilterPop() *Goldsmith { func (goldsmith *Goldsmith) End(targetDir string) []error { goldsmith.targetDir = targetDir + var wg sync.WaitGroup goldsmith.Chain(&saver{ clean: goldsmith.clean, + wg: &wg, }) + wg.Add(1) + for _, context := range goldsmith.contexts { go context.step() } + wg.Wait() + return goldsmith.errors } diff --git a/saver.go b/saver.go index 0545f49..3b8f4a9 100644 --- a/saver.go +++ b/saver.go @@ -3,11 +3,13 @@ package goldsmith import ( "os" "path/filepath" + "sync" ) type saver struct { clean bool tokens map[string]bool + wg *sync.WaitGroup } func (*saver) Name() string { @@ -29,6 +31,8 @@ func (saver *saver) Process(context *Context, file *File) error { } func (saver *saver) Finalize(context *Context) error { + defer saver.wg.Done() + if !saver.clean { return nil }