Skip to content

Commit

Permalink
Forward go mod tidy stdout/stderr
Browse files Browse the repository at this point in the history
This is a command that can fail (in my case I think for stupid reasons
in a hell of my own construction, but nonetheless).  Right now we just
get
```
$ go run github.com/Khan/webapp/dev/cmd/gqlgen
tidy failed: go mod tidy failed: exit status 1
exit status 3
```
which is not the most informative.  Now, instead, we'll forward its
output to our own stdout/stderr rather than devnull.
  • Loading branch information
benjaminjkraft committed Sep 15, 2021
1 parent ce7a8ee commit 43b56cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/code/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"

Expand Down Expand Up @@ -155,6 +156,8 @@ func (p *Packages) Evict(importPath string) {
func (p *Packages) ModTidy() error {
p.packages = nil
tidyCmd := exec.Command("go", "mod", "tidy")
tidyCmd.Stdout = os.Stdout
tidyCmd.Stderr = os.Stdout
if err := tidyCmd.Run(); err != nil {
return fmt.Errorf("go mod tidy failed: %w", err)
}
Expand Down

0 comments on commit 43b56cb

Please sign in to comment.