mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02: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:
@@ -119,7 +119,7 @@ func NewClient(cfg ClientConfig) *Client {
|
||||
// Client contains most of the API provided by this package.
|
||||
type Client struct {
|
||||
fs afero.Fs
|
||||
logger *loggers.Logger
|
||||
logger loggers.Logger
|
||||
|
||||
noVendor glob.Glob
|
||||
|
||||
@@ -329,7 +329,7 @@ func (c *Client) Get(args ...string) error {
|
||||
}
|
||||
|
||||
func (c *Client) get(args ...string) error {
|
||||
if err := c.runGo(context.Background(), c.logger.Out, append([]string{"get"}, args...)...); err != nil {
|
||||
if err := c.runGo(context.Background(), c.logger.Out(), append([]string{"get"}, args...)...); err != nil {
|
||||
errors.Wrapf(err, "failed to get %q", args)
|
||||
}
|
||||
return nil
|
||||
@@ -339,7 +339,7 @@ func (c *Client) get(args ...string) error {
|
||||
// If path is empty, Go will try to guess.
|
||||
// If this succeeds, this project will be marked as Go Module.
|
||||
func (c *Client) Init(path string) error {
|
||||
err := c.runGo(context.Background(), c.logger.Out, "mod", "init", path)
|
||||
err := c.runGo(context.Background(), c.logger.Out(), "mod", "init", path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to init modules")
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func (c *Client) Clean(pattern string) error {
|
||||
}
|
||||
_, err = hugofs.MakeReadableAndRemoveAllModulePkgDir(c.fs, m.Dir)
|
||||
if err == nil {
|
||||
c.logger.FEEDBACK.Printf("hugo: cleaned module cache for %q", m.Path)
|
||||
c.logger.Printf("hugo: cleaned module cache for %q", m.Path)
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -560,7 +560,7 @@ func (c *Client) runGo(
|
||||
|
||||
if strings.Contains(stderr.String(), "invalid version: unknown revision") {
|
||||
// See https://github.com/gohugoio/hugo/issues/6825
|
||||
c.logger.FEEDBACK.Println(`hugo: you need to manually edit go.mod to resolve the unknown revision.`)
|
||||
c.logger.Println(`hugo: you need to manually edit go.mod to resolve the unknown revision.`)
|
||||
}
|
||||
|
||||
_, ok := err.(*exec.ExitError)
|
||||
@@ -616,7 +616,7 @@ func (c *Client) shouldVendor(path string) bool {
|
||||
// ClientConfig configures the module Client.
|
||||
type ClientConfig struct {
|
||||
Fs afero.Fs
|
||||
Logger *loggers.Logger
|
||||
Logger loggers.Logger
|
||||
|
||||
// If set, it will be run before we do any duplicate checks for modules
|
||||
// etc.
|
||||
|
@@ -124,11 +124,11 @@ type ModulesConfig struct {
|
||||
GoModulesFilename string
|
||||
}
|
||||
|
||||
func (m *ModulesConfig) setActiveMods(logger *loggers.Logger) error {
|
||||
func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error {
|
||||
var activeMods Modules
|
||||
for _, mod := range m.AllModules {
|
||||
if !mod.Config().HugoVersion.IsValid() {
|
||||
logger.WARN.Printf(`Module %q is not compatible with this Hugo version; run "hugo mod graph" for more information.`, mod.Path())
|
||||
logger.Warnf(`Module %q is not compatible with this Hugo version; run "hugo mod graph" for more information.`, mod.Path())
|
||||
}
|
||||
if !mod.Disabled() {
|
||||
activeMods = append(activeMods, mod)
|
||||
@@ -140,7 +140,7 @@ func (m *ModulesConfig) setActiveMods(logger *loggers.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModulesConfig) finalize(logger *loggers.Logger) error {
|
||||
func (m *ModulesConfig) finalize(logger loggers.Logger) error {
|
||||
for _, mod := range m.AllModules {
|
||||
m := mod.(*moduleAdapter)
|
||||
m.mounts = filterUnwantedMounts(m.mounts)
|
||||
@@ -422,7 +422,7 @@ func (c *collector) applyThemeConfig(tc *moduleAdapter) error {
|
||||
}
|
||||
themeCfg, err = metadecoders.Default.UnmarshalToMap(data, metadecoders.TOML)
|
||||
if err != nil {
|
||||
c.logger.WARN.Printf("Failed to read module config for %q in %q: %s", tc.Path(), themeTOML, err)
|
||||
c.logger.Warnf("Failed to read module config for %q in %q: %s", tc.Path(), themeTOML, err)
|
||||
} else {
|
||||
maps.ToLower(themeCfg)
|
||||
}
|
||||
@@ -480,7 +480,7 @@ func (c *collector) collect() {
|
||||
defer c.logger.PrintTimerIfDelayed(time.Now(), "hugo: collected modules")
|
||||
d := debounce.New(2 * time.Second)
|
||||
d(func() {
|
||||
c.logger.FEEDBACK.Println("hugo: downloading modules …")
|
||||
c.logger.Println("hugo: downloading modules …")
|
||||
})
|
||||
defer d(func() {})
|
||||
|
||||
|
Reference in New Issue
Block a user