remove panicks and fix setup

This commit is contained in:
Henrique Dias 2016-07-02 23:29:47 +01:00
parent fd24071850
commit acfda6b4b7
2 changed files with 24 additions and 21 deletions

View File

@ -133,7 +133,7 @@ func RunHugo(c *Config, force bool) {
}
if err := commands.Run(c.Hugo, c.Args, c.Root); err != nil {
log.Panic(err)
log.Println(err)
}
}

View File

@ -1,6 +1,7 @@
package hugo
import (
"fmt"
"io/ioutil"
"log"
"net/http"
@ -59,7 +60,7 @@ func setup(c *caddy.Controller) error {
if create {
err := commands.Run(conf.Hugo, []string{"new", "site", conf.Root, "--force"}, ".")
if err != nil {
log.Panic(err)
log.Fatal(err)
}
}
@ -67,16 +68,16 @@ func setup(c *caddy.Controller) error {
bytes, err := ioutil.ReadFile(filepath.Clean(conf.Root + "/config." + format))
if err != nil {
log.Panic(err)
}
log.Println(err)
fmt.Printf("Can't get the default frontmatter from the configuration. %s will be used.\n", format)
} else {
bytes = directory.AppendFrontMatterRune(bytes, format)
f, err := frontmatter.Unmarshal(bytes)
if err != nil {
log.Panic(err)
}
log.Println(err)
fmt.Printf("Can't get the default frontmatter from the configuration. %s will be used.\n", format)
} else {
kind := reflect.TypeOf(f)
if kind == reflect.TypeOf(map[interface{}]interface{}{}) {
@ -89,6 +90,8 @@ func setup(c *caddy.Controller) error {
format = val.(string)
}
}
}
}
// Generates the Hugo website for the first time the plugin is activated.
go RunHugo(conf, true)