This commit is contained in:
Henrique Dias
2016-02-20 12:04:12 +00:00
parent 9e135967cb
commit 5fd7adec7a
5 changed files with 44 additions and 43 deletions

View File

@@ -164,9 +164,20 @@ func ParseComponents(r *http.Request) []string {
}
// Run is used to run the static website generator
func Run(c *config.Config) {
func Run(c *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 := RunCommand("hugo", c.Args, c.Path); err != nil {
log.Panic(err)
}
@@ -181,6 +192,15 @@ func RunCommand(command string, args []string, path string) error {
return cmd.Run()
}
func stringInSlice(a string, list []string) (bool, int) {
for i, b := range list {
if b == a {
return true, i
}
}
return false, 0
}
var splitCapitalizeExceptions = map[string]string{
"youtube": "YouTube",
"github": "GitHub",