Skip to content

Commit

Permalink
fix: only run generate code once (#3436)
Browse files Browse the repository at this point in the history
* fix: only run generate code once

* correct order of operations
  • Loading branch information
Brookke authored Dec 18, 2024
1 parent 0d2b9d2 commit fbe0246
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions api/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ func Generate(cfg *config.Config, option ...Option) error {
return fmt.Errorf("merging type systems failed: %w", err)
}

if err = codegen.GenerateCode(data); err != nil {
return fmt.Errorf("generating core failed: %w", err)
}

if !cfg.SkipModTidy {
if err = cfg.Packages.ModTidy(); err != nil {
return fmt.Errorf("tidy failed: %w", err)
}
}

for _, p := range plugins {
if mut, ok := p.(plugin.CodeGenerator); ok {
err := mut.GenerateCode(data)
Expand All @@ -140,6 +130,11 @@ func Generate(cfg *config.Config, option ...Option) error {
return fmt.Errorf("generating core failed: %w", err)
}

if !cfg.SkipModTidy {
if err = cfg.Packages.ModTidy(); err != nil {
return fmt.Errorf("tidy failed: %w", err)
}
}
if !cfg.SkipValidation {
if err := validate(cfg); err != nil {
return fmt.Errorf("validation failed: %w", err)
Expand Down

0 comments on commit fbe0246

Please sign in to comment.