Skip to content

Commit bd734bb

Browse files
authored
fix(xgenny): run all dry runners before the wet run in the xgenny pkg (#4000)
* run all dry runners before the we runners for the xgenny pkg * add changelog --------- Co-authored-by: Pantani <Pantani>
1 parent 3ca22be commit bd734bb

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [#3953](https://github.com/ignite/cli/pull/3953) Fix apps `Stdout` is redirected to `Stderr`
2424
- [#3863](https://github.com/ignite/cli/pull/3963) Fix breaking issue for app client API when reading app chain info
2525
- [#3969](https://github.com/ignite/cli/pull/3969) Get first config validator using a getter to avoid index errors
26+
- [#4000](https://github.com/ignite/cli/pull/4000) Run all dry runners before the wet run in the `xgenny` pkg
2627

2728
## [`v28.2.0`](https://github.com/ignite/cli/releases/tag/v28.2.0)
2829

ignite/pkg/xgenny/run.go

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,49 +38,51 @@ func RunWithValidation(
3838
gens ...*genny.Generator,
3939
) (sm SourceModification, err error) {
4040
// run executes the provided runner with the provided generator
41-
run := func(runner *genny.Runner, gen *genny.Generator) error {
42-
err := runner.With(gen)
43-
if err != nil {
44-
return err
45-
}
46-
return runner.Run()
47-
}
48-
for _, gen := range gens {
49-
// check with a dry runner the generators
50-
dryRunner := DryRunner(context.Background())
51-
if err := run(dryRunner, gen); err != nil {
52-
if errors.Is(err, os.ErrNotExist) {
53-
return sm, &dryRunError{err}
41+
run := func(runner *genny.Runner, gens []*genny.Generator) error {
42+
for _, gen := range gens {
43+
if err := runner.With(gen); err != nil {
44+
return err
45+
}
46+
if err := runner.Run(); err != nil {
47+
return err
5448
}
55-
return sm, err
5649
}
57-
if err := tracer.Err(); err != nil {
58-
return sm, err
50+
return nil
51+
}
52+
// check with a dry runner the generators
53+
dryRunner := DryRunner(context.Background())
54+
if err := run(dryRunner, gens); err != nil {
55+
if errors.Is(err, os.ErrNotExist) {
56+
return sm, &dryRunError{err}
5957
}
58+
return sm, err
59+
}
60+
if err := tracer.Err(); err != nil {
61+
return sm, err
62+
}
6063

61-
// fetch the source modification
62-
sm = NewSourceModification()
63-
for _, file := range dryRunner.Results().Files {
64-
fileName := file.Name()
65-
_, err := os.Stat(fileName)
66-
67-
//nolint:gocritic
68-
if os.IsNotExist(err) {
69-
// if the file doesn't exist in the source, it means it has been created by the runner
70-
sm.AppendCreatedFiles(fileName)
71-
} else if err != nil {
72-
return sm, err
73-
} else {
74-
// the file has been modified by the runner
75-
sm.AppendModifiedFiles(fileName)
76-
}
77-
}
64+
// fetch the source modification
65+
sm = NewSourceModification()
66+
for _, file := range dryRunner.Results().Files {
67+
fileName := file.Name()
68+
_, err := os.Stat(fileName)
7869

79-
// execute the modification with a wet runner
80-
if err := run(genny.WetRunner(context.Background()), gen); err != nil {
70+
//nolint:gocritic
71+
if os.IsNotExist(err) {
72+
// if the file doesn't exist in the source, it means it has been created by the runner
73+
sm.AppendCreatedFiles(fileName)
74+
} else if err != nil {
8175
return sm, err
76+
} else {
77+
// the file has been modified by the runner
78+
sm.AppendModifiedFiles(fileName)
8279
}
8380
}
81+
82+
// execute the modification with a wet runner
83+
if err := run(genny.WetRunner(context.Background()), gens); err != nil {
84+
return sm, err
85+
}
8486
return sm, nil
8587
}
8688

0 commit comments

Comments
 (0)