mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
commands: Make the error handling for the mod commands more lenient
So it at least is possible to do a `hugo mod clean --all` if the cache is in a funky state.
This commit is contained in:
@@ -323,8 +323,11 @@ func (c *commandeer) loadConfig() error {
|
||||
// We should improve the error handling here,
|
||||
// but with hugo mod init and similar there is a chicken and egg situation
|
||||
// with modules already configured in config.toml, so ignore those errors.
|
||||
if c.mustHaveConfigFile || !moduleNotFoundRe.MatchString(err.Error()) {
|
||||
if c.mustHaveConfigFile || (c.failOnInitErr && !moduleNotFoundRe.MatchString(err.Error())) {
|
||||
return err
|
||||
} else {
|
||||
// Just make it a warning.
|
||||
c.logger.Warnln(err)
|
||||
}
|
||||
} else if c.mustHaveConfigFile && len(configFiles) == 0 {
|
||||
return hugolib.ErrNoConfigFile
|
||||
|
Reference in New Issue
Block a user