Skip to content

Commit

Permalink
chore: address @anuraaga's feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Jul 5, 2023
1 parent da15ffc commit 1ce51de
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
Expand Down Expand Up @@ -76,25 +75,23 @@ func Lint() error {
return err
}

if d.IsDir() {
if !d.IsDir() {
return nil
}

runGoModTidy := strings.HasSuffix(path, "go.mod")
if runGoModTidy {
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = filepath.Dir(path)
if _, err := os.Stat(filepath.Join(path, "go.work")); err == nil {
cmd := exec.Command("go", "work", "sync")
cmd.Dir = path
out, err := cmd.Output()
fmt.Printf(string(out))
if err != nil {
return err
}
}

runGoWorkSync := strings.HasSuffix(path, "go.work") || runGoModTidy
if runGoWorkSync {
cmd := exec.Command("go", "work", "sync")
cmd.Dir = filepath.Dir(path)
if _, err := os.Stat(filepath.Join(path, "go.mod")); err == nil {
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = path
out, err := cmd.Output()
fmt.Printf(string(out))
if err != nil {
Expand Down

0 comments on commit 1ce51de

Please sign in to comment.