1
0
mirror of https://github.com/beego/bee.git synced 2024-11-21 23:50:54 +00:00

do not exit while encouter a file that's already exist

This commit is contained in:
ZhengYang 2014-08-04 16:33:39 +08:00
parent fc62745b4f
commit 7a4d5f2798

View File

@ -440,8 +440,8 @@ func writeModelFiles(tables []*Table, mPath string) {
fpath := path.Join(mPath, filename+".go") fpath := path.Join(mPath, filename+".go")
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666)
if err != nil { if err != nil {
ColorLog("[ERRO] %v\n", err) ColorLog("[WARN] %v\n", err)
os.Exit(2) continue
} }
template := "" template := ""
if tb.Pk == "" { if tb.Pk == "" {
@ -471,8 +471,8 @@ func writeControllerFiles(tables []*Table, cPath string) {
fpath := path.Join(cPath, filename+".go") fpath := path.Join(cPath, filename+".go")
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666)
if err != nil { if err != nil {
ColorLog("[ERRO] %v\n", err) ColorLog("[WARN] %v\n", err)
os.Exit(2) continue
} }
fileStr := strings.Replace(CTRL_TPL, "{{ctrlName}}", camelCase(tb.Name), -1) fileStr := strings.Replace(CTRL_TPL, "{{ctrlName}}", camelCase(tb.Name), -1)
if _, err := f.WriteString(fileStr); err != nil { if _, err := f.WriteString(fileStr); err != nil {
@ -504,8 +504,8 @@ func writeRouterFile(tables []*Table, rPath string) {
routerStr = strings.Replace(routerStr, "{{projectName}}", projectName, 1) routerStr = strings.Replace(routerStr, "{{projectName}}", projectName, 1)
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) f, err := os.OpenFile(fpath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666)
if err != nil { if err != nil {
ColorLog("[ERRO] %v\n", err) ColorLog("[WARN] %v\n", err)
os.Exit(2) return
} }
if _, err := f.WriteString(routerStr); err != nil { if _, err := f.WriteString(routerStr); err != nil {
ColorLog("[ERRO] Could not write router file to %s\n", fpath) ColorLog("[ERRO] Could not write router file to %s\n", fpath)