1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-30 06:19:00 +01:00

better error reporting for failed plugins

This commit is contained in:
Oliver Steele 2017-07-26 10:02:12 -04:00
parent a81cd37701
commit c6b0dcc8cf
2 changed files with 11 additions and 6 deletions

View File

@ -102,6 +102,9 @@ func getCurrentRepo(c *config.Config) (nwo string, err error) {
return
}
m := regexp.MustCompile(`origin\s+https://github.com/(.+?)/(.+)\.git\b`).FindStringSubmatch(string(out))
if m == nil {
return "", fmt.Errorf("jekyll-github-metadata failed to find current repository")
}
owner, name := m[1], m[2]
nwo = fmt.Sprintf("%s/%s", owner, name)
return

View File

@ -1,6 +1,7 @@
package site
import (
"log"
"time"
"github.com/osteele/gojekyll/pages"
@ -17,7 +18,11 @@ func (s *Site) ToLiquid() interface{} {
s.Lock()
defer s.Unlock()
if len(s.drop) == 0 {
s.initializeDrop()
if err := s.initializeDrop(); err != nil {
if err != nil {
log.Fatalf("ModifySiteDrop failed: %s\n", err)
}
}
}
return s.drop
}
@ -28,7 +33,7 @@ func (s *Site) MarshalYAML() (interface{}, error) {
return s.ToLiquid(), nil
}
func (s *Site) initializeDrop() {
func (s *Site) initializeDrop() error {
drop := templates.MergeVariableMaps(s.config.Variables, map[string]interface{}{
"data": s.data,
"documents": s.docs,
@ -48,12 +53,9 @@ func (s *Site) initializeDrop() {
drop["collections"] = collections
s.drop = drop
s.setPostVariables()
err := s.runHooks(func(h plugins.Plugin) error {
return s.runHooks(func(h plugins.Plugin) error {
return h.ModifySiteDrop(s, drop)
})
if err != nil {
panic(err)
}
}
func (s *Site) setPageContent() error {