Skip to content

Commit

Permalink
format and mod tidy for generated model (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
sio4 authored Dec 3, 2021
1 parent 8573d1c commit e572a4d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions soda/cmd/generate/model_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package generate

import (
"context"
"os"
"os/exec"

"github.com/gobuffalo/attrs"
"github.com/gobuffalo/fizz"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/genny/v2/gogen"
"github.com/gobuffalo/logger"
"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/pop/v6/genny/fizz/ctable"
Expand Down Expand Up @@ -67,9 +70,23 @@ var ModelCmd = &cobra.Command{
if err != nil {
return err
}
run.With(g)

// format generated go files
pwd, _ := os.Getwd()
g, err = gogen.Fmt(pwd)
if err != nil {
return err
}
run.With(g)

// generated modules may have new dependencies
if _, err := os.Stat("go.mod"); err == nil {
g = genny.New()
g.Command(exec.Command("go", "mod", "tidy"))
run.With(g)
}

// Mount migrations generator
if !modelCmdConfig.SkipMigration {
p := cmd.Flag("path")
Expand Down

0 comments on commit e572a4d

Please sign in to comment.