diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ac726b5..79d8963f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Issue when running `sedge` without sudo. +- Issue when `sedge` generates clients datadirs without sudo. ## [v1.2.0] - 2023-06-06 diff --git a/cli/actions/generation.go b/cli/actions/generation.go index 30ed3c12..429fdc9b 100644 --- a/cli/actions/generation.go +++ b/cli/actions/generation.go @@ -106,11 +106,14 @@ func (s *sedgeActions) Generate(options GenerateOptions) (generate.GenData, erro } for _, datadir := range datadirs { if datadir.createIf { - if _, err := os.Stat(datadir.path); os.IsNotExist(err) { + _, err := os.Stat(datadir.path) + if os.IsNotExist(err) { err = os.MkdirAll(datadir.path, 0o755) if err != nil { return options.GenerationData, err } + } else { + return options.GenerationData, err } } } diff --git a/internal/pkg/clients/clients.go b/internal/pkg/clients/clients.go index ec1b75ef..ab85489c 100644 --- a/internal/pkg/clients/clients.go +++ b/internal/pkg/clients/clients.go @@ -45,7 +45,7 @@ b. error Error if any */ func (c ClientInfo) SupportedClients(clientType ClientType) (clientsNames []string, err error) { - files, err := templates.Envs.ReadDir(strings.Join([]string{"envs", c.Network, clientType.ToString()}, "/")) + files, err := templates.Envs.ReadDir(strings.Join([]string{"envs", c.Network, clientType.String()}, "/")) if err != nil { return } diff --git a/internal/pkg/clients/types.go b/internal/pkg/clients/types.go index f4183a8b..0ccdfa4f 100644 --- a/internal/pkg/clients/types.go +++ b/internal/pkg/clients/types.go @@ -23,13 +23,13 @@ import ( type ClientType string -func (ct ClientType) ToString() string { +func (ct ClientType) String() string { return string(ct) } func (ct ClientType) ToTitle() string { caser := cases.Title(language.English) - return caser.String(ct.ToString()) + return caser.String(ct.String()) } const (