From e572a4dd838f00d86c9afb8a7dec36df7d2c4062 Mon Sep 17 00:00:00 2001 From: Yonghwan SO Date: Fri, 3 Dec 2021 22:13:09 +0900 Subject: [PATCH] format and mod tidy for generated model (#677) --- soda/cmd/generate/model_cmd.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/soda/cmd/generate/model_cmd.go b/soda/cmd/generate/model_cmd.go index ec7b6bef..be16f01e 100644 --- a/soda/cmd/generate/model_cmd.go +++ b/soda/cmd/generate/model_cmd.go @@ -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" @@ -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")