1
0
mirror of https://github.com/beego/bee.git synced 2024-11-21 18:40:54 +00:00

Merge pull request #3 from beego/develop

Develop
This commit is contained in:
Sergey Lanzman 2017-03-10 11:44:26 +02:00 committed by GitHub
commit 74baba4f63

28
run.go
View File

@ -23,7 +23,7 @@ import (
)
var cmdRun = &Command{
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-vendor=true] [-e=folderToExclude] [-tags=goBuildTags] [-runmode=BEEGO_RUNMODE]",
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-vendor=true] [-e=folderToExclude] [-ex=extraPackageToWatch] [-tags=goBuildTags] [-runmode=BEEGO_RUNMODE]",
Short: "Run the application by starting a local development server",
Long: `
Run command will supervise the filesystem of the application for any changes, and recompile/restart it.
@ -53,6 +53,8 @@ var (
currentGoPath string
// Current runmode
runmode string
// Extra directories
extraPackages strFlags
)
func init() {
@ -63,13 +65,13 @@ func init() {
cmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Enable watch vendor folder.")
cmdRun.Flag.StringVar(&buildTags, "tags", "", "Set the build tags. See: https://golang.org/pkg/go/build/")
cmdRun.Flag.StringVar(&runmode, "runmode", "", "Set the Beego run mode.")
cmdRun.Flag.Var(&extraPackages, "ex", "List of extra package to watch.")
exit = make(chan bool)
}
func runApp(cmd *Command, args []string) int {
if len(args) == 0 || args[0] == "watchall" {
currpath, _ = os.Getwd()
if found, _gopath, _ := SearchGOPATHs(currpath); found {
appname = path.Base(currpath)
currentGoPath = _gopath
@ -123,6 +125,28 @@ func runApp(cmd *Command, args []string) int {
paths = append(paths, strings.Replace(p, "$GOPATH", currentGoPath, -1))
}
if len(extraPackages) > 0 {
// get the full path
for _, packagePath := range extraPackages {
if found, _, _fullPath := SearchGOPATHs(packagePath); found {
readAppDirectories(_fullPath, &paths)
} else {
logger.Warnf("No extra package '%s' found in your GOPATH", packagePath)
}
}
// let paths unique
strSet := make(map[string]struct{})
for _, p := range paths {
strSet[p] = struct{}{}
}
paths = make([]string, len(strSet))
index := 0
for i := range strSet {
paths[index] = i
index++
}
}
files := []string{}
for _, arg := range mainFiles {
if len(arg) > 0 {