From a37be85dd336ab91622c923996790866f1240d01 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 24 Sep 2024 16:45:50 -0700 Subject: [PATCH] fixup --- internal/super/generate.go | 13 +++++++++---- internal/super/generator/contract_template.go | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index 00f074fc8..24cd0e2d3 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -100,10 +100,15 @@ func generateContract( ) (result command.Result, err error) { g := generator.NewGenerator("", state, logger, false, true) name := util.StripCDCExtension(args[0]) - err = g.Create( - generator.ContractTemplate{Name: name}, - generator.TestTemplate{Name: name + "_test", Data: map[string]interface{}{"ContractName": "Counter"}}, - ) + + templates := []generator.TemplateItem{ + generator.ContractTemplate{Name: name, SkipTests: generateFlags.SkipTests, SaveState: true}, + } + if !generateFlags.SkipTests { + templates = append(templates, generator.TestTemplate{Name: name + "_test", Data: map[string]interface{}{"ContractName": "Counter"}}) + } + + err = g.Create() return nil, err } diff --git a/internal/super/generator/contract_template.go b/internal/super/generator/contract_template.go index 3c319192d..783e9952a 100644 --- a/internal/super/generator/contract_template.go +++ b/internal/super/generator/contract_template.go @@ -16,8 +16,8 @@ type ContractTemplate struct { Account string TemplatePath string Data map[string]interface{} - skipTests bool - saveState bool + SkipTests bool + SaveState bool } var _ TemplateItem = ContractTemplate{} @@ -50,7 +50,7 @@ func (c ContractTemplate) GetTargetPath() string { func (c ContractTemplate) UpdateState(state *flowkit.State) error { var aliases config.Aliases - if c.skipTests != true { + if c.SkipTests != true { aliases = config.Aliases{{ Network: config.TestingNetwork.Name, Address: flowsdk.HexToAddress("0x0000000000000007"), @@ -65,7 +65,7 @@ func (c ContractTemplate) UpdateState(state *flowkit.State) error { state.Contracts().AddOrUpdate(contract) - if c.saveState { + if c.SaveState { err := state.SaveDefault() // TODO: Support adding a target project directory if err != nil { return fmt.Errorf("error saving to flow.json: %w", err)