filebrowser/_stuff/run.go

30 lines
569 B
Go
Raw Normal View History

2016-03-03 21:15:54 +00:00
package hugo
import (
2016-02-21 11:51:31 +00:00
"log"
"os"
2016-03-03 21:15:54 +00:00
2016-03-06 20:37:49 +00:00
"github.com/hacdias/caddy-hugo/tools/commands"
2016-06-21 14:28:15 +00:00
"github.com/hacdias/caddy-hugo/tools/variables"
2016-02-21 11:51:31 +00:00
)
2016-03-06 19:18:46 +00:00
// Run is used to run the static website generator
2016-06-21 14:28:15 +00:00
func Run(c *Config, force bool) {
2016-03-06 19:18:46 +00:00
os.RemoveAll(c.Path + "public")
// Prevent running if watching is enabled
2016-06-21 14:28:15 +00:00
if b, pos := variables.StringInSlice("--watch", c.Args); b && !force {
2016-03-06 19:18:46 +00:00
if len(c.Args) > pos && c.Args[pos+1] != "false" {
return
}
if len(c.Args) == pos+1 {
return
}
}
2016-03-06 20:37:49 +00:00
if err := commands.Run(c.Hugo, c.Args, c.Path); err != nil {
2016-03-06 19:18:46 +00:00
log.Panic(err)
}
}