mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
do not exit while encouter a file that's already exist
This commit is contained in:
parent
fc62745b4f
commit
7a4d5f2798
12
g_models.go
12
g_models.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user