fix: fixed kratos "new" command #1218 (#1221)

* fix: fixed kratos  "new" command
pull/1223/head
包子 3 years ago committed by GitHub
parent 5559923193
commit 41ad9061db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      cmd/kratos/internal/project/new.go
  2. 3
      cmd/kratos/internal/project/project.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(

@ -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

Loading…
Cancel
Save