mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
39 lines
707 B
Go
39 lines
707 B
Go
|
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
|
||
|
}
|