Add some more output if loading modules takes time

Also include the time to collect modules etc. in the "Total in ..." time reported for the `hugo` command.

Fixes #6519
This commit is contained in:
Bjørn Erik Pedersen 2019-11-21 13:07:52 +01:00
parent 14a985f8ab
commit 2dcc1318d1
6 changed files with 55 additions and 12 deletions

View file

@ -259,7 +259,7 @@ func (c *Client) Vendor() error {
// Get runs "go get" with the supplied arguments.
func (c *Client) Get(args ...string) error {
if err := c.runGo(context.Background(), os.Stdout, 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
@ -269,7 +269,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(), os.Stdout, "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")
}
@ -410,6 +410,8 @@ func (c *Client) runGo(
return nil
}
//defer c.logger.PrintTimer(time.Now(), fmt.Sprint(args))
stderr := new(bytes.Buffer)
cmd := exec.CommandContext(ctx, "go", args...)