mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Better error handling when rendering error found when in watch mode
In watch mode it should continue to watch for changes, in any other mode it should exit with a -1 error code so can check for success when scripting
This commit is contained in:
@@ -68,6 +68,7 @@ type Site struct {
|
||||
Target target.Output
|
||||
Alias target.AliasPublisher
|
||||
Completed chan bool
|
||||
RunMode runmode
|
||||
}
|
||||
|
||||
type SiteInfo struct {
|
||||
@@ -79,6 +80,14 @@ type SiteInfo struct {
|
||||
Config *Config
|
||||
}
|
||||
|
||||
type runmode struct {
|
||||
Watching bool
|
||||
}
|
||||
|
||||
func (s *Site) Running() bool {
|
||||
return s.RunMode.Watching
|
||||
}
|
||||
|
||||
func init() {
|
||||
DefaultTimer = nitro.Initalize()
|
||||
}
|
||||
@@ -576,7 +585,11 @@ func (s *Site) render(d interface{}, out string, layouts ...string) (err error)
|
||||
go func() {
|
||||
err = s.renderThing(d, layout, renderWriter)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
// Behavior here should be dependent on if running in server or watch mode.
|
||||
fmt.Println(fmt.Errorf("Rendering error: %v", err))
|
||||
if !s.Running() {
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
Reference in New Issue
Block a user