Skip to content

Commit

Permalink
Update kobweb create to search descriptions if names fail
Browse files Browse the repository at this point in the history
So `kobweb create worker` finds:

```
examples/imageprocessor: An image processing demo that showcases Kobweb Workers
```
  • Loading branch information
bitspittle committed Mar 7, 2024
1 parent d6d5de2 commit dc335dd
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ fun handleCreate(repo: String, branch: String, templateName: String?) = session
if (templateName != null) {
templateRoots.indexOfFirst { templateFile ->
templateFile.getName(tempDir).contains(templateName)
}.takeIf { it >= 0 } ?:
templateRoots.indexOfFirst { templateFile ->
// If here, there was no name match, but maybe a description will match? e.g. "worker" will
// find the "imageprocessor" template which mentions it demonstrates how workers work.
templateFile.template.metadata.description.contains(templateName, ignoreCase = true)
}.takeIf { it >= 0 } ?: 0
} else 0
)
Expand Down

0 comments on commit dc335dd

Please sign in to comment.