From e39dc9fb7f36dde1a707fdb53e69aecb21ce028a Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Mon, 21 Nov 2016 15:23:08 +0100 Subject: [PATCH] #323: Removes the check if the current path is a Beego project --- pack.go | 4 ---- run.go | 4 ++-- util.go | 11 ++++------- version.go | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pack.go b/pack.go index 2695840..30f7b50 100644 --- a/pack.go +++ b/pack.go @@ -478,10 +478,6 @@ func packApp(cmd *Command, args []string) int { 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) appName := path.Base(thePath) diff --git a/run.go b/run.go index bdee001..ecf09ae 100644 --- a/run.go +++ b/run.go @@ -76,7 +76,7 @@ func runApp(cmd *Command, args []string) int { appname = path.Base(currpath) currentGoPath = _gopath } else { - logger.Fatalf("No Beego application '%s' found in your GOPATH", currpath) + logger.Fatalf("No application '%s' found in your GOPATH", currpath) } } else { // 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 appname = path.Base(currpath) } 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) { diff --git a/util.go b/util.go index c3cc754..04a3c17 100644 --- a/util.go +++ b/util.go @@ -17,7 +17,6 @@ package main import ( "fmt" "io/ioutil" - "log" "os" "os/exec" "path" @@ -67,7 +66,8 @@ func GetGOPATHs() []string { 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{} hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`) // Walk the application path tree to look for main files. @@ -86,7 +86,7 @@ func isBeegoProject(thePath string) bool { }) 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 } @@ -116,9 +116,6 @@ func SearchGOPATHs(app string) (bool, string, string) { } if isExist(currentPath) { - if !isBeegoProject(currentPath) { - continue - } return true, gopath, currentPath } } @@ -134,7 +131,7 @@ func askForConfirmation() bool { var response string _, err := fmt.Scanln(&response) if err != nil { - log.Fatal(err) + logger.Fatalf("%s", err) } okayResponses := []string{"y", "Y", "yes", "Yes", "YES"} nokayResponses := []string{"n", "N", "no", "No", "NO"} diff --git a/version.go b/version.go index 02e1414..60dbfd7 100644 --- a/version.go +++ b/version.go @@ -124,7 +124,7 @@ func getGoVersion() string { ) 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] }