Skip to content

Commit

Permalink
formatting templates files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobbrewer1 committed Nov 3, 2024
1 parent 841eee3 commit 9add882
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,10 @@ func (g *generateCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface
}
}

if err := generation.FmtTemplates(g.outputLocation); err != nil {
slog.Error("Error formatting templates", slog.String("outputLocation", g.outputLocation), slog.String("error", err.Error()))
return subcommands.ExitFailure
}

return subcommands.ExitSuccess
}
7 changes: 7 additions & 0 deletions pkg/generation/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,10 @@ func InstallGoimports() error {
cmd.Stderr = os.Stderr
return cmd.Run()
}

func FmtTemplates(outputLoc string) error {
cmd := exec.Command("goimports", "-w", outputLoc)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

0 comments on commit 9add882

Please sign in to comment.