filebrowser/utils/_unused/hugo/hugo.go

30 lines
564 B
Go
Raw Normal View History

2016-06-25 20:57:10 +00:00
package hugo
import (
"log"
"os"
"github.com/hacdias/caddy-hugo/config"
"github.com/hacdias/caddy-hugo/tools/commands"
)
// Run is used to run the static website generator
func Run(c *config.Config.Config, force bool) {
os.RemoveAll(c.Path + "public")
// Prevent running if watching is enabled
if b, pos := 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)
}
}