diff options
author | Alexander Borsuk <me@alex.bio> | 2018-01-10 18:55:22 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-10 18:26:42 +0100 |
commit | 5235a5bf5ef44b3789341e1d25b681a7bb14771a (patch) | |
tree | 2e5c73bcb6397b3595213ca30f03586eaa6a54d0 /commands | |
parent | 1921a70ab1a8761917bea8c74afaa790719fe958 (diff) |
Correct fix for --cleanDestinationDir flag
Fixes #4246
Fixes #4248
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 0e7b755f7..51375ea8a 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -561,25 +561,36 @@ func (c *commandeer) fullBuild(watches ...bool) error { }() } - g.Go(func() error { + copyStaticFunc := func() error { cnt, err := c.copyStatic() if err != nil { return fmt.Errorf("Error copying static files: %s", err) } langCount = cnt return nil - }) - - g.Go(func() error { + } + buildSitesFunc := func() error { if err := c.buildSites(); err != nil { return fmt.Errorf("Error building site: %s", err) } - return nil - }) - - if err := g.Wait(); err != nil { - return err + } + // Do not copy static files and build sites in parallel if cleanDestinationDir is enabled. + // This flag deletes all static resources in /public folder that are missing in /static, + // and it does so at the end of copyStatic() call. + if c.Cfg.GetBool("cleanDestinationDir") { + if err := copyStaticFunc(); err != nil { + return err + } + if err := buildSitesFunc(); err != nil { + return err + } + } else { + g.Go(copyStaticFunc) + g.Go(buildSitesFunc) + if err := g.Wait(); err != nil { + return err + } } for _, s := range Hugo.Sites { |