Skip to content

Commit

Permalink
Code review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Nov 4, 2022
1 parent f8a7cfe commit 45dc376
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions cmd/urfave-cli-genflags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,28 @@ func runGenFlags(cCtx *cli.Context) error {
return err
}

if !cCtx.IsSet("altsrc") {
genTestTmpl, err := template.New("gen_test").Parse(TestTemplateString)
if err != nil {
return err
}
if cCtx.IsSet("altsrc") {
return nil
}

genTestBuf := &bytes.Buffer{}
if err := genTestTmpl.Execute(genTestBuf, spec); err != nil {
return err
}
genTestTmpl, err := template.New("gen_test").Parse(TestTemplateString)
if err != nil {
return err
}

if err := os.WriteFile(cCtx.Path("generated-test-output"), genTestBuf.Bytes(), 0644); err != nil {
return err
}
genTestBuf := &bytes.Buffer{}
if err := genTestTmpl.Execute(genTestBuf, spec); err != nil {
return err
}

if _, err := sh(cCtx.Context, cCtx.Path("goimports"), "-w", cCtx.Path("generated-test-output")); err != nil {
return err
}
if err := os.WriteFile(cCtx.Path("generated-test-output"), genTestBuf.Bytes(), 0644); err != nil {
return err
}

if _, err := sh(cCtx.Context, cCtx.Path("goimports"), "-w", cCtx.Path("generated-test-output")); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 45dc376

Please sign in to comment.