mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 22:21:07 +03:00
Allow getJSON errors to be ignored
This change is mostly motivated to get a more stable CI build (we're building the Hugo site there, with Instagram and Twitter shortcodes sometimes failing). Fixes #7866
This commit is contained in:
parent
8cbe2bbfad
commit
fdfa4a5fe6
52 changed files with 318 additions and 221 deletions
|
@ -130,7 +130,7 @@ func initializeConfig(mustHaveConfigFile, running bool,
|
|||
|
||||
}
|
||||
|
||||
func (c *commandeer) createLogger(cfg config.Provider, running bool) (*loggers.Logger, error) {
|
||||
func (c *commandeer) createLogger(cfg config.Provider, running bool) (loggers.Logger, error) {
|
||||
var (
|
||||
logHandle = ioutil.Discard
|
||||
logThreshold = jww.LevelWarn
|
||||
|
@ -374,12 +374,12 @@ func (c *commandeer) initMemProfile() {
|
|||
|
||||
f, err := os.Create(c.h.memprofile)
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println("could not create memory profile: ", err)
|
||||
c.logger.Errorf("could not create memory profile: ", err)
|
||||
}
|
||||
defer f.Close()
|
||||
runtime.GC() // get up-to-date statistics
|
||||
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||
c.logger.ERROR.Println("could not write memory profile: ", err)
|
||||
c.logger.Errorf("could not write memory profile: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ func (c *commandeer) build() error {
|
|||
if createCounter, ok := c.destinationFs.(hugofs.DuplicatesReporter); ok {
|
||||
dupes := createCounter.ReportDuplicates()
|
||||
if dupes != "" {
|
||||
c.logger.WARN.Println("Duplicate target paths:", dupes)
|
||||
c.logger.Warnln("Duplicate target paths:", dupes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -532,8 +532,8 @@ func (c *commandeer) build() error {
|
|||
baseWatchDir := c.Cfg.GetString("workingDir")
|
||||
rootWatchDirs := getRootWatchDirsStr(baseWatchDir, watchDirs)
|
||||
|
||||
c.logger.FEEDBACK.Printf("Watching for changes in %s%s{%s}\n", baseWatchDir, helpers.FilePathSeparator, rootWatchDirs)
|
||||
c.logger.FEEDBACK.Println("Press Ctrl+C to stop")
|
||||
c.logger.Printf("Watching for changes in %s%s{%s}\n", baseWatchDir, helpers.FilePathSeparator, rootWatchDirs)
|
||||
c.logger.Println("Press Ctrl+C to stop")
|
||||
watcher, err := c.newWatcher(watchDirs...)
|
||||
checkErr(c.Logger, err)
|
||||
defer watcher.Close()
|
||||
|
@ -590,7 +590,7 @@ func (c *commandeer) doWithPublishDirs(f func(sourceFs *filesystems.SourceFilesy
|
|||
staticFilesystems := c.hugo().BaseFs.SourceFilesystems.Static
|
||||
|
||||
if len(staticFilesystems) == 0 {
|
||||
c.logger.INFO.Println("No static directories found to sync")
|
||||
c.logger.Infoln("No static directories found to sync")
|
||||
return langCount, nil
|
||||
}
|
||||
|
||||
|
@ -662,13 +662,13 @@ func (c *commandeer) copyStaticTo(sourceFs *filesystems.SourceFilesystem) (uint6
|
|||
syncer.Delete = c.Cfg.GetBool("cleanDestinationDir")
|
||||
|
||||
if syncer.Delete {
|
||||
c.logger.INFO.Println("removing all files from destination that don't exist in static dirs")
|
||||
c.logger.Infoln("removing all files from destination that don't exist in static dirs")
|
||||
|
||||
syncer.DeleteFilter = func(f os.FileInfo) bool {
|
||||
return f.IsDir() && strings.HasPrefix(f.Name(), ".")
|
||||
}
|
||||
}
|
||||
c.logger.INFO.Println("syncing static files to", publishDir)
|
||||
c.logger.Infoln("syncing static files to", publishDir)
|
||||
|
||||
// because we are using a baseFs (to get the union right).
|
||||
// set sync src to root
|
||||
|
@ -689,7 +689,7 @@ func (c *commandeer) firstPathSpec() *helpers.PathSpec {
|
|||
|
||||
func (c *commandeer) timeTrack(start time.Time, name string) {
|
||||
elapsed := time.Since(start)
|
||||
c.logger.FEEDBACK.Printf("%s in %v ms", name, int(1000*elapsed.Seconds()))
|
||||
c.logger.Printf("%s in %v ms", name, int(1000*elapsed.Seconds()))
|
||||
}
|
||||
|
||||
// getDirList provides NewWatcher() with a list of directories to watch for changes.
|
||||
|
@ -698,7 +698,7 @@ func (c *commandeer) getDirList() ([]string, error) {
|
|||
|
||||
walkFn := func(path string, fi hugofs.FileMetaInfo, err error) error {
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println("walker: ", err)
|
||||
c.logger.Errorln("walker: ", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ func (c *commandeer) getDirList() ([]string, error) {
|
|||
|
||||
w := hugofs.NewWalkway(hugofs.WalkwayConfig{Logger: c.logger, Info: fi, WalkFn: walkFn})
|
||||
if err := w.Walk(); err != nil {
|
||||
c.logger.ERROR.Println("walker: ", err)
|
||||
c.logger.Errorln("walker: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,8 +740,8 @@ func (c *commandeer) buildSites() (err error) {
|
|||
func (c *commandeer) handleBuildErr(err error, msg string) {
|
||||
c.buildErr = err
|
||||
|
||||
c.logger.ERROR.Print(msg + ":\n\n")
|
||||
c.logger.ERROR.Println(helpers.FirstUpper(err.Error()))
|
||||
c.logger.Errorln(msg + ":\n")
|
||||
c.logger.Errorln(helpers.FirstUpper(err.Error()))
|
||||
if !c.h.quiet && c.h.verbose {
|
||||
herrors.PrintStackTraceFromErr(err)
|
||||
}
|
||||
|
@ -822,13 +822,13 @@ func (c *commandeer) fullRebuild(changeType string) {
|
|||
if !c.paused {
|
||||
_, err := c.copyStatic()
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println(err)
|
||||
c.logger.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = c.buildSites()
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println(err)
|
||||
c.logger.Errorln(err)
|
||||
} else if !c.h.buildWatch && !c.Cfg.GetBool("disableLiveReload") {
|
||||
livereload.ForceRefresh()
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ func (c *commandeer) newWatcher(dirList ...string) (*watcher.Batcher, error) {
|
|||
// Identifies changes to config (config.toml) files.
|
||||
configSet := make(map[string]bool)
|
||||
|
||||
c.logger.FEEDBACK.Println("Watching for config changes in", strings.Join(c.configFiles, ", "))
|
||||
c.logger.Println("Watching for config changes in", strings.Join(c.configFiles, ", "))
|
||||
for _, configFile := range c.configFiles {
|
||||
watcher.Add(configFile)
|
||||
configSet[configFile] = true
|
||||
|
@ -879,7 +879,7 @@ func (c *commandeer) newWatcher(dirList ...string) (*watcher.Batcher, error) {
|
|||
}
|
||||
case err := <-watcher.Errors:
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println("Error while watching:", err)
|
||||
c.logger.Errorln("Error while watching:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,9 +895,9 @@ func (c *commandeer) printChangeDetected(typ string) {
|
|||
}
|
||||
msg += " detected, rebuilding site."
|
||||
|
||||
c.logger.FEEDBACK.Println(msg)
|
||||
c.logger.Println(msg)
|
||||
const layout = "2006-01-02 15:04:05.000 -0700"
|
||||
c.logger.FEEDBACK.Println(time.Now().Format(layout))
|
||||
c.logger.Println(time.Now().Format(layout))
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -979,7 +979,7 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
|||
return
|
||||
}
|
||||
|
||||
c.logger.INFO.Println("Received System Events:", evs)
|
||||
c.logger.Infoln("Received System Events:", evs)
|
||||
|
||||
staticEvents := []fsnotify.Event{}
|
||||
dynamicEvents := []fsnotify.Event{}
|
||||
|
@ -1059,7 +1059,7 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
|||
|
||||
walkAdder := func(path string, f hugofs.FileMetaInfo, err error) error {
|
||||
if f.IsDir() {
|
||||
c.logger.FEEDBACK.Println("adding created directory to watchlist", path)
|
||||
c.logger.Println("adding created directory to watchlist", path)
|
||||
if err := watcher.Add(path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1091,15 +1091,15 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
|||
c.printChangeDetected("Static files")
|
||||
|
||||
if c.Cfg.GetBool("forceSyncStatic") {
|
||||
c.logger.FEEDBACK.Printf("Syncing all static files\n")
|
||||
c.logger.Printf("Syncing all static files\n")
|
||||
_, err := c.copyStatic()
|
||||
if err != nil {
|
||||
c.logger.ERROR.Println("Error copying static files to publish dir:", err)
|
||||
c.logger.Errorln("Error copying static files to publish dir:", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err := staticSyncer.syncsStaticEvents(staticEvents); err != nil {
|
||||
c.logger.ERROR.Println("Error syncing static files to publish dir:", err)
|
||||
c.logger.Errorln("Error syncing static files to publish dir:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue