Skip to content

Commit

Permalink
Fix: Scaffolding now properly populates templatesge nam… (StyraInc#277)
Browse files Browse the repository at this point in the history
* fix, scaffolding now populates the templates with correct package names, imports the correct path 'as rule' and pupulates 'title' correctly in test.
  • Loading branch information
ThomasKingoTM authored and srenatus committed Oct 1, 2024
1 parent d2a34ed commit 2331ea2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,19 @@ func scaffoldBuiltinRule(params newRuleCommandParams) error {
func templateValues(params newRuleCommandParams) TemplateValues {
var tmplNameValue string

if strings.Contains(params.name, "-") {
tmplNameValue = `["` + params.name + `"]`
} else {
tmplNameValue = "." + params.name
}

var tmplNameTestValue string

if strings.Contains(params.name, "-") {
tmplNameTestValue = `["` + params.name + `_test"]`
} else {
dashedNameValue := strings.ReplaceAll(params.name, "_", "-")

switch {
case strings.Contains(params.name, "-"):
tmplNameValue = `["` + dashedNameValue + `"]`
tmplNameTestValue = `["` + dashedNameValue + `_test"]`
case strings.Contains(params.name, "_"):
tmplNameValue = `["` + dashedNameValue + `"]`
tmplNameTestValue = `["` + dashedNameValue + `_test"]`
default:
tmplNameValue = "." + params.name
tmplNameTestValue = "." + params.name + "_test"
}

Expand Down

0 comments on commit 2331ea2

Please sign in to comment.