refactor file|path (#1409)
Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/gogen"
|
||||
conf "github.com/tal-tech/go-zero/tools/goctl/config"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -49,7 +50,7 @@ func CreateServiceCommand(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = util.MkdirIfNotExist(abs)
|
||||
err = pathx.MkdirIfNotExist(abs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,10 +75,10 @@ func CreateServiceCommand(c *cli.Context) error {
|
||||
}
|
||||
|
||||
if len(home) > 0 {
|
||||
util.RegisterGoctlHome(home)
|
||||
pathx.RegisterGoctlHome(home)
|
||||
}
|
||||
|
||||
text, err := util.LoadTemplate(category, apiTemplateFile, apiTemplate)
|
||||
text, err := pathx.LoadTemplate(category, apiTemplateFile, apiTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package new
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -23,12 +23,12 @@ func Category() string {
|
||||
|
||||
// Clean cleans the generated deployment files.
|
||||
func Clean() error {
|
||||
return util.Clean(category)
|
||||
return pathx.Clean(category)
|
||||
}
|
||||
|
||||
// GenTemplates generates api template files.
|
||||
func GenTemplates(_ *cli.Context) error {
|
||||
return util.InitTemplates(category, templates)
|
||||
return pathx.InitTemplates(category, templates)
|
||||
}
|
||||
|
||||
// RevertTemplate reverts the given template file to the default value.
|
||||
@@ -37,7 +37,7 @@ func RevertTemplate(name string) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("%s: no such file name", name)
|
||||
}
|
||||
return util.CreateTemplate(category, name, content)
|
||||
return pathx.CreateTemplate(category, name, content)
|
||||
}
|
||||
|
||||
// Update updates the template files to the templates built in current goctl.
|
||||
@@ -47,5 +47,5 @@ func Update() error {
|
||||
return err
|
||||
}
|
||||
|
||||
return util.InitTemplates(category, templates)
|
||||
return pathx.InitTemplates(category, templates)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user