feat & fix: detailed logging & correct path processing

This commit is contained in:
2025-03-08 22:07:50 +07:00
parent fb59bf979c
commit 9fd83b52e6
2 changed files with 9 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"text/template"
)
@@ -19,7 +20,8 @@ type ServiceTemplateContext struct {
}
func GenerateService(structName, mkPath string) {
serviceFile, err := os.Create(mkPath + "/" + strings.ToLower(structName) + ".service.ts")
servicePath := filepath.Join(mkPath, strings.ToLower(structName)+".service.ts")
serviceFile, err := os.Create(servicePath)
if err != nil {
log.Fatalf("Failed to create service file: %s", err)
}
@@ -47,4 +49,5 @@ func GenerateService(structName, mkPath string) {
if err != nil {
log.Fatalf("Failed to execute template: %s", err)
}
log.Printf("Service for `%s` model is written: %s", structName, servicePath)
}