This commit is contained in:
Henrique Dias
2016-06-21 15:28:15 +01:00
parent 8879f22932
commit b43d8e2465
67 changed files with 977 additions and 3381 deletions

29
_stuff/run.go Normal file
View File

@@ -0,0 +1,29 @@
package hugo
import (
"log"
"os"
"github.com/hacdias/caddy-hugo/tools/commands"
"github.com/hacdias/caddy-hugo/tools/variables"
)
// Run is used to run the static website generator
func Run(c *Config, force bool) {
os.RemoveAll(c.Path + "public")
// Prevent running if watching is enabled
if b, pos := variables.StringInSlice("--watch", c.Args); b && !force {
if len(c.Args) > pos && c.Args[pos+1] != "false" {
return
}
if len(c.Args) == pos+1 {
return
}
}
if err := commands.Run(c.Hugo, c.Args, c.Path); err != nil {
log.Panic(err)
}
}