modules: Fix "hugo mod get -u" with no arguments

Fixes #6826
Closes #6825
This commit is contained in:
Bjørn Erik Pedersen
2020-01-30 09:08:49 +01:00
parent 8f08cdd0ac
commit 49ef647203
4 changed files with 33 additions and 19 deletions

View File

@@ -20,8 +20,6 @@ import (
"golang.org/x/sync/semaphore"
"github.com/gohugoio/hugo/modules"
"io/ioutil"
"github.com/gohugoio/hugo/common/herrors"
@@ -312,14 +310,8 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
doWithCommandeer,
doWithConfig)
if err != nil {
if mustHaveConfigFile {
return err
}
if err != hugolib.ErrNoConfigFile && !modules.IsNotExist(err) {
return err
}
if err != nil && mustHaveConfigFile {
return err
} else if mustHaveConfigFile && len(configFiles) == 0 {
return hugolib.ErrNoConfigFile
}

View File

@@ -77,6 +77,7 @@ Run "go help get" for more information. All flags available for "go get" is also
` + commonUsage,
RunE: func(cmd *cobra.Command, args []string) error {
return c.withModsClient(false, func(c *modules.Client) error {
// We currently just pass on the flags we get to Go and
// need to do the flag handling manually.
if len(args) == 1 && args[0] == "-h" {