mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
unzip to swagger while not swagger-2
This commit is contained in:
parent
8bda698fce
commit
b5bf9d07c3
@ -650,7 +650,7 @@ func checkEnv(appname string) (apppath, packpath string, err error) {
|
||||
for _, gpath := range gps {
|
||||
gsrcpath := path.Join(gpath, "src")
|
||||
if strings.HasPrefix(currpath, gsrcpath) {
|
||||
return currpath, currpath[len(gsrcpath):], nil
|
||||
return currpath, currpath[len(gsrcpath)+1:], nil
|
||||
}
|
||||
}
|
||||
|
||||
|
12
rundocs.go
12
rundocs.go
@ -20,6 +20,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var cmdRundocs = &Command{
|
||||
@ -120,6 +121,7 @@ func unzipAndDelete(src string) error {
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
rp := strings.NewReplacer("swagger-"+swaggerVersion, "swagger")
|
||||
for _, f := range r.File {
|
||||
rc, err := f.Open()
|
||||
if err != nil {
|
||||
@ -127,11 +129,12 @@ func unzipAndDelete(src string) error {
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
fname := rp.Replace(f.Name)
|
||||
if f.FileInfo().IsDir() {
|
||||
os.MkdirAll(f.Name, f.Mode())
|
||||
os.MkdirAll(fname, f.Mode())
|
||||
} else {
|
||||
f, err := os.OpenFile(
|
||||
f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
||||
fname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -143,11 +146,6 @@ func unzipAndDelete(src string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
os.RemoveAll("swagger")
|
||||
err = os.Rename("swagger-"+swaggerVersion, "swagger")
|
||||
if err != nil {
|
||||
ColorLog("[%s]Rename swagger-%s to swagger:%s\n", ERRO, swaggerVersion, err)
|
||||
}
|
||||
ColorLog("[%s]Start delete src file %s\n", INFO, src)
|
||||
return os.RemoveAll(src)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user