mirror of
https://github.com/go-kratos/kratos.git
synced 2025-02-07 13:31:50 +02:00
fix(cmd/run): fix the problem of looking for the cmd directory outside the project (#1166)
* fix(cmd/run): fix the problem of looking for the cmd directory outside the project
This commit is contained in:
parent
6e9ce7af22
commit
ac8c27ff9f
@ -68,6 +68,7 @@ func Run(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
func findCMD(base string) (string, []string, error) {
|
||||
var root bool
|
||||
next := func(dir string) (string, []string, error) {
|
||||
var (
|
||||
cmdDir string
|
||||
@ -88,6 +89,9 @@ func findCMD(base string) (string, []string, error) {
|
||||
cmdDir = filepath.Join(walkPath, "..")
|
||||
return nil
|
||||
}
|
||||
if info.Name() == "go.mod" {
|
||||
root = true
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return cmdDir, cmdPath, err
|
||||
@ -100,6 +104,9 @@ func findCMD(base string) (string, []string, error) {
|
||||
if len(res) > 0 {
|
||||
return cmdDir, res, nil
|
||||
}
|
||||
if root {
|
||||
break
|
||||
}
|
||||
base = filepath.Join(base, "..")
|
||||
}
|
||||
return "", []string{base}, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user