1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 10:10:53 +00:00

Merge pull request #324 from amrfaissal/nonbeego-support

Removes the check if the current path is a Beego project
This commit is contained in:
Faissal Elamraoui 2016-11-22 09:58:03 +01:00 committed by GitHub
commit 215ef4485a
4 changed files with 7 additions and 14 deletions

View File

@ -478,10 +478,6 @@ func packApp(cmd *Command, args []string) int {
logger.Fatalf("Application path does not exist: %s", thePath) logger.Fatalf("Application path does not exist: %s", thePath)
} }
if isBeegoProject(thePath) == false {
logger.Fatal("Bee does not support non Beego project")
}
logger.Infof("Packaging application on '%s'...", thePath) logger.Infof("Packaging application on '%s'...", thePath)
appName := path.Base(thePath) appName := path.Base(thePath)

4
run.go
View File

@ -76,7 +76,7 @@ func runApp(cmd *Command, args []string) int {
appname = path.Base(currpath) appname = path.Base(currpath)
currentGoPath = _gopath currentGoPath = _gopath
} else { } else {
logger.Fatalf("No Beego application '%s' found in your GOPATH", currpath) logger.Fatalf("No application '%s' found in your GOPATH", currpath)
} }
} else { } else {
// Check if passed Bee application path/name exists in the GOPATH(s) // Check if passed Bee application path/name exists in the GOPATH(s)
@ -85,7 +85,7 @@ func runApp(cmd *Command, args []string) int {
currentGoPath = _gopath currentGoPath = _gopath
appname = path.Base(currpath) appname = path.Base(currpath)
} else { } else {
logger.Fatalf("No Beego application '%s' found in your GOPATH", args[0]) logger.Fatalf("No application '%s' found in your GOPATH", args[0])
} }
if strings.HasSuffix(appname, ".go") && isExist(currpath) { if strings.HasSuffix(appname, ".go") && isExist(currpath) {

11
util.go
View File

@ -17,7 +17,6 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"os/exec" "os/exec"
"path" "path"
@ -67,7 +66,8 @@ func GetGOPATHs() []string {
return paths return paths
} }
func isBeegoProject(thePath string) bool { // IsBeegoProject checks whether the current path is a Beego application or not
func IsBeegoProject(thePath string) bool {
mainFiles := []string{} mainFiles := []string{}
hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`) hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`)
// Walk the application path tree to look for main files. // Walk the application path tree to look for main files.
@ -86,7 +86,7 @@ func isBeegoProject(thePath string) bool {
}) })
if err != nil { if err != nil {
log.Fatalf("Unable to walk '%s' tree: %v", thePath, err) logger.Fatalf("Unable to walk '%s' tree: %v", thePath, err)
return false return false
} }
@ -116,9 +116,6 @@ func SearchGOPATHs(app string) (bool, string, string) {
} }
if isExist(currentPath) { if isExist(currentPath) {
if !isBeegoProject(currentPath) {
continue
}
return true, gopath, currentPath return true, gopath, currentPath
} }
} }
@ -134,7 +131,7 @@ func askForConfirmation() bool {
var response string var response string
_, err := fmt.Scanln(&response) _, err := fmt.Scanln(&response)
if err != nil { if err != nil {
log.Fatal(err) logger.Fatalf("%s", err)
} }
okayResponses := []string{"y", "Y", "yes", "Yes", "YES"} okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
nokayResponses := []string{"n", "N", "no", "No", "NO"} nokayResponses := []string{"n", "N", "no", "No", "NO"}

View File

@ -124,7 +124,7 @@ func getGoVersion() string {
) )
if cmdOut, err = exec.Command("go", "version").Output(); err != nil { if cmdOut, err = exec.Command("go", "version").Output(); err != nil {
logger.Fatalf("There was an error running go version command: %s", err) logger.Fatalf("There was an error running 'go version' command: %s", err)
} }
return strings.Split(string(cmdOut), " ")[2] return strings.Split(string(cmdOut), " ")[2]
} }