filebrowser/utils/_unused/hugo/hugo.go

39 lines
707 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)
}
}
func stringInSlice(a string, list []string) (bool, int) {
for i, b := range list {
if b == a {
return true, i
}
}
return false, 0
}