diff --git a/cmd/kratos/internal/project/new.go b/cmd/kratos/internal/project/new.go index 5c5197b6d..434f03ad1 100644 --- a/cmd/kratos/internal/project/new.go +++ b/cmd/kratos/internal/project/new.go @@ -15,6 +15,7 @@ import ( // Project is a project template. type Project struct { Name string + Path string } // New new a project from remote repo. @@ -36,7 +37,7 @@ func (p *Project) New(ctx context.Context, dir string, layout string, branch str } fmt.Printf("🚀 Creating service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout) repo := base.NewRepo(layout, branch) - if err := repo.CopyTo(ctx, to, p.Name, []string{".git", ".github"}); err != nil { + if err := repo.CopyTo(ctx, to, p.Path, []string{".git", ".github"}); err != nil { return err } os.Rename( diff --git a/cmd/kratos/internal/project/project.go b/cmd/kratos/internal/project/project.go index 04a7016b2..3e4de68d3 100644 --- a/cmd/kratos/internal/project/project.go +++ b/cmd/kratos/internal/project/project.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "path" "time" "github.com/AlecAivazis/survey/v2" @@ -49,7 +50,7 @@ func run(cmd *cobra.Command, args []string) { } else { name = args[0] } - p := &Project{Name: name} + p := &Project{Name: path.Base(name), Path: name} if err := p.New(ctx, wd, repoURL, branch); err != nil { fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) return