Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Scaffolding now properly populates templatesge nam… #277

Merged
merged 6 commits into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading