fix: This fixes #247

Moved isBeegoProject(app) method from pack.go to util.go. Rewrite it
to walk the application folder tree looking for main files.
This commit is contained in:
Faissal Elamraoui
2016-09-26 20:25:15 +02:00
parent f7d2e04e07
commit 287af20d1a
2 changed files with 36 additions and 22 deletions

19
pack.go
View File

@ -21,7 +21,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
path "path/filepath"
@ -454,24 +453,6 @@ func packDirectory(excludePrefix []string, excludeSuffix []string,
return
}
func isBeegoProject(thePath string) bool {
fh, _ := os.Open(thePath)
fis, _ := fh.Readdir(-1)
regex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`)
for _, fi := range fis {
if fi.IsDir() == false && strings.HasSuffix(fi.Name(), ".go") {
data, err := ioutil.ReadFile(path.Join(thePath, fi.Name()))
if err != nil {
continue
}
if len(regex.Find(data)) > 0 {
return true
}
}
}
return false
}
func packApp(cmd *Command, args []string) int {
ShowShortVersionBanner()