mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 03:40:49 +00:00
Fixed error in window os
This commit is contained in:
parent
3c8ed9adfc
commit
7ceff43db6
15
parser.go
15
parser.go
@ -23,7 +23,6 @@ import (
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -58,7 +57,8 @@ func init() {
|
||||
|
||||
func parserPkg(pkgRealpath, pkgpath string) error {
|
||||
rep := strings.NewReplacer("\\", "_", "/", "_", ".", "_")
|
||||
commentFilename = coomentPrefix + rep.Replace(strings.Replace(pkgRealpath, AppPath, "", -1)) + ".go"
|
||||
commentFilename, _ = filepath.Rel(AppPath, pkgRealpath)
|
||||
commentFilename = coomentPrefix + rep.Replace(commentFilename) + ".go"
|
||||
if !compareFile(pkgRealpath) {
|
||||
logs.Info(pkgRealpath + " no changed")
|
||||
return nil
|
||||
@ -174,7 +174,7 @@ func genRouterCode(pkgRealpath string) {
|
||||
}
|
||||
}
|
||||
if globalinfo != "" {
|
||||
f, err := os.Create(path.Join(getRouterDir(pkgRealpath), commentFilename))
|
||||
f, err := os.Create(filepath.Join(getRouterDir(pkgRealpath), commentFilename))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -184,7 +184,7 @@ func genRouterCode(pkgRealpath string) {
|
||||
}
|
||||
|
||||
func compareFile(pkgRealpath string) bool {
|
||||
if !utils.FileExists(path.Join(getRouterDir(pkgRealpath), commentFilename)) {
|
||||
if !utils.FileExists(filepath.Join(getRouterDir(pkgRealpath), commentFilename)) {
|
||||
return true
|
||||
}
|
||||
if utils.FileExists(lastupdateFilename) {
|
||||
@ -235,11 +235,12 @@ func getpathTime(pkgRealpath string) (lastupdate int64, err error) {
|
||||
func getRouterDir(pkgRealpath string) string {
|
||||
dir := filepath.Dir(pkgRealpath)
|
||||
for {
|
||||
d := path.Join(dir, "routers")
|
||||
if dir == AppPath {
|
||||
d := filepath.Join(dir, "routers")
|
||||
if utils.FileExists(d) {
|
||||
return d
|
||||
}
|
||||
if utils.FileExists(d) {
|
||||
|
||||
if r, _ := filepath.Rel(dir, AppPath); r == "." {
|
||||
return d
|
||||
}
|
||||
// Parent dir.
|
||||
|
Loading…
Reference in New Issue
Block a user