// Set bash-completion
validConfigFilenames := []string{"json", "js", "yaml", "yml", "toml", "tml"}
- HugoCmd.PersistentFlags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
+ _ = HugoCmd.PersistentFlags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
}
// initHugoBuildCommonFlags initialize common flags related to the Hugo build.
// Set bash-completion.
// Each flag must first be defined before using the SetAnnotation() call.
- cmd.Flags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("destination", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
+ _ = cmd.Flags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ _ = cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
+ _ = cmd.Flags().SetAnnotation("destination", cobra.BashCompSubdirsInDir, []string{})
+ _ = cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
}
func initBenchmarkBuildingFlags(cmd *cobra.Command) {
hugoCmdV = HugoCmd
// Set bash-completion
- HugoCmd.PersistentFlags().SetAnnotation("logFile", cobra.BashCompFilenameExt, []string{})
+ _ = HugoCmd.PersistentFlags().SetAnnotation("logFile", cobra.BashCompFilenameExt, []string{})
}
// InitializeConfig initializes a config file with sensible default configuration flags.
config.Set("cacheDir", helpers.GetTempDir("hugo_cache", fs.Source))
}
- c.initFs(fs)
+ if err := c.initFs(fs); err != nil {
+ return nil, err
+ }
cfg.Logger.INFO.Println("Using config file:", viper.ConfigFileUsed())
return nil
}
- helpers.SymbolicWalk(c.Fs.Source, dataDir, walker)
- helpers.SymbolicWalk(c.Fs.Source, c.PathSpec().AbsPathify(c.Cfg.GetString("contentDir")), walker)
- helpers.SymbolicWalk(c.Fs.Source, i18nDir, walker)
- helpers.SymbolicWalk(c.Fs.Source, c.PathSpec().AbsPathify(c.Cfg.GetString("layoutDir")), walker)
+ // SymbolicWalk will log anny ERRORs
+ _ = helpers.SymbolicWalk(c.Fs.Source, dataDir, walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, c.PathSpec().AbsPathify(c.Cfg.GetString("contentDir")), walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, i18nDir, walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, c.PathSpec().AbsPathify(c.Cfg.GetString("layoutDir")), walker)
- helpers.SymbolicWalk(c.Fs.Source, staticDir, walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, staticDir, walker)
if c.PathSpec().ThemeSet() {
- helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "layouts"), walker)
- helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "static"), walker)
- helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "i18n"), walker)
- helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "data"), walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "layouts"), walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "static"), walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "i18n"), walker)
+ _ = helpers.SymbolicWalk(c.Fs.Source, filepath.Join(themesDir, "data"), walker)
}
walkAdder := func(path string, f os.FileInfo, err error) error {
if f.IsDir() {
c.Logger.FEEDBACK.Println("adding created directory to watchlist", path)
- watcher.Add(path)
+ if err := watcher.Add(path); err != nil {
+ return err
+ }
}
return nil
}
// When mkdir -p is used, only the top directory triggers an event (at least on OSX)
if ev.Op&fsnotify.Create == fsnotify.Create {
if s, err := c.Fs.Source.Stat(ev.Name); err == nil && s.Mode().IsDir() {
- helpers.SymbolicWalk(c.Fs.Source, ev.Name, walkAdder)
+ _ = helpers.SymbolicWalk(c.Fs.Source, ev.Name, walkAdder)
}
}
// If file doesn't exist in any static dir, remove it
toRemove := filepath.Join(publishDir, relPath)
logger.Println("File no longer exists in static dir, removing", toRemove)
- c.Fs.Destination.RemoveAll(toRemove)
+ _ = c.Fs.Destination.RemoveAll(toRemove)
} else if err == nil {
// If file still exists, sync it
logger.Println("Syncing", relPath, "to", publishDir)
func (s *Site) RegisterMediaTypes() {
for _, mt := range s.mediaTypesConfig {
// The last one will win if there are any duplicates.
- mime.AddExtensionType("."+mt.Suffix, mt.Type()+"; charset=utf-8")
+ _ = mime.AddExtensionType("."+mt.Suffix, mt.Type()+"; charset=utf-8")
}
}
}
if len(dataChanged) > 0 {
- s.readDataFromSourceFS()
+ if err := s.readDataFromSourceFS(); err != nil {
+ s.Log.ERROR.Println(err)
+ }
}
// If a content file changes, we need to reload only it and re-render the entire site.
path = []byte(s)
}
transformer := transform.NewChain(transform.AbsURLInXML)
- transformer.Apply(outBuffer, renderBuffer, path)
+ if err := transformer.Apply(outBuffer, renderBuffer, path); err != nil {
+ helpers.DistinctErrorLog.Println(err)
+ return nil
+ }
return s.publish(dest, outBuffer)
}
transformer := transform.NewChain(transformLinks...)
- transformer.Apply(outBuffer, renderBuffer, path)
+ if err := transformer.Apply(outBuffer, renderBuffer, path); err != nil {
+ helpers.DistinctErrorLog.Println(err)
+ return nil
+ }
return s.publish(dest, outBuffer)
}