mirror of https://github.com/beego/bee.git
add a parm for build app name. exclude go.mod go.sum
This commit is contained in:
parent
6d18c6a289
commit
cc77534090
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/beego/bee/cmd/commands"
|
"github.com/beego/bee/cmd/commands"
|
||||||
"github.com/beego/bee/cmd/commands/version"
|
"github.com/beego/bee/cmd/commands/version"
|
||||||
beeLogger "github.com/beego/bee/logger"
|
"github.com/beego/bee/logger"
|
||||||
"github.com/beego/bee/utils"
|
"github.com/beego/bee/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ var CmdPack = &commands.Command{
|
||||||
|
|
||||||
var (
|
var (
|
||||||
appPath string
|
appPath string
|
||||||
|
appName string
|
||||||
excludeP string
|
excludeP string
|
||||||
excludeS string
|
excludeS string
|
||||||
outputP string
|
outputP string
|
||||||
|
@ -57,6 +58,7 @@ func init() {
|
||||||
fs := flag.NewFlagSet("pack", flag.ContinueOnError)
|
fs := flag.NewFlagSet("pack", flag.ContinueOnError)
|
||||||
fs.StringVar(&appPath, "p", "", "Set the application path. Defaults to the current path.")
|
fs.StringVar(&appPath, "p", "", "Set the application path. Defaults to the current path.")
|
||||||
fs.BoolVar(&build, "b", true, "Tell the command to do a build for the current platform. Defaults to true.")
|
fs.BoolVar(&build, "b", true, "Tell the command to do a build for the current platform. Defaults to true.")
|
||||||
|
fs.StringVar(&appName, "a", "", "Set the application name. Defaults to the dir name.")
|
||||||
fs.StringVar(&buildArgs, "ba", "", "Specify additional args for Go build.")
|
fs.StringVar(&buildArgs, "ba", "", "Specify additional args for Go build.")
|
||||||
fs.Var(&buildEnvs, "be", "Specify additional env variables for Go build. e.g. GOARCH=arm.")
|
fs.Var(&buildEnvs, "be", "Specify additional env variables for Go build. e.g. GOARCH=arm.")
|
||||||
fs.StringVar(&outputP, "o", "", "Set the compressed file output path. Defaults to the current path.")
|
fs.StringVar(&outputP, "o", "", "Set the compressed file output path. Defaults to the current path.")
|
||||||
|
@ -445,7 +447,9 @@ func packApp(cmd *commands.Command, args []string) int {
|
||||||
|
|
||||||
beeLogger.Log.Infof("Packaging application on '%s'...", thePath)
|
beeLogger.Log.Infof("Packaging application on '%s'...", thePath)
|
||||||
|
|
||||||
appName := path.Base(thePath)
|
if len(appName) == 0 {
|
||||||
|
appName = path.Base(thePath)
|
||||||
|
}
|
||||||
|
|
||||||
goos := runtime.GOOS
|
goos := runtime.GOOS
|
||||||
if v, found := syscall.Getenv("GOOS"); found {
|
if v, found := syscall.Getenv("GOOS"); found {
|
||||||
|
@ -470,7 +474,7 @@ func packApp(cmd *commands.Command, args []string) int {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if build {
|
if build {
|
||||||
beeLogger.Log.Info("Building application...")
|
beeLogger.Log.Infof("Building application (%v)...", appName)
|
||||||
var envs []string
|
var envs []string
|
||||||
for _, env := range buildEnvs {
|
for _, env := range buildEnvs {
|
||||||
parts := strings.SplitN(env, "=", 2)
|
parts := strings.SplitN(env, "=", 2)
|
||||||
|
@ -553,7 +557,8 @@ func packApp(cmd *commands.Command, args []string) int {
|
||||||
exs = append(exs, p)
|
exs = append(exs, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exs = append(exs, `go.mod`)
|
||||||
|
exs = append(exs, `go.sum`)
|
||||||
var exr []*regexp.Regexp
|
var exr []*regexp.Regexp
|
||||||
for _, r := range excludeR {
|
for _, r := range excludeR {
|
||||||
if len(r) > 0 {
|
if len(r) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue