1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-24 03:46:37 +02:00

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

* fix: fixed kratos  "new" command
This commit is contained in:
包子 2021-07-21 10:02:28 +08:00 committed by GitHub
parent 5559923193
commit 41ad9061db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import (
// Project is a project template. // Project is a project template.
type Project struct { type Project struct {
Name string Name string
Path string
} }
// New new a project from remote repo. // 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) fmt.Printf("🚀 Creating service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout)
repo := base.NewRepo(layout, branch) 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 return err
} }
os.Rename( os.Rename(

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"path"
"time" "time"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
@ -49,7 +50,7 @@ func run(cmd *cobra.Command, args []string) {
} else { } else {
name = args[0] 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 { if err := p.New(ctx, wd, repoURL, branch); err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
return return