File tree Expand file tree Collapse file tree 6 files changed +28
-4
lines changed Expand file tree Collapse file tree 6 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ build_pkg: ""
83
83
# build tags
84
84
build_tags: ""
85
85
86
+ # Commands that can be executed before running the app
87
+ #external_cmd:
88
+ # - swag init
89
+
86
90
# Whether to prohibit automatic operation
87
91
disable_run: false
88
92
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ build_tags: ""
70
70
# 是否禁止自动运行
71
71
disable_run: false
72
72
73
+ #在执行app执行的命令 ,例如 swag init
74
+ #external_cmd:
75
+ # - swag init
73
76
```
74
77
75
78
## 微信公众号
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ type config struct {
19
19
WatchExts []string `yaml:"watch_exts"`
20
20
//需要追加监听的目录,默认是当前文件夹,
21
21
WatchPaths []string `yaml:"watch_paths"`
22
+ //运行前额外执行的命令
23
+ ExternalCmds []string `yaml:"external_cmds"`
22
24
//执行时的额外参数
23
25
CmdArgs []string `yaml:"cmd_args"`
24
26
//构建时的额外参数
Original file line number Diff line number Diff line change @@ -25,4 +25,7 @@ output: ./example
25
25
26
26
# build_tags: ""
27
27
28
+ # external_cmd:
29
+ # - go version
30
+
28
31
disable_run : false
Original file line number Diff line number Diff line change @@ -174,12 +174,24 @@ func Start(appname string) {
174
174
appname = "./" + appname
175
175
}
176
176
177
- cmd = exec .Command (appname )
177
+ for _ , externalCmd := range cfg .ExternalCmds {
178
+ log .Infof ("Run external cmd '%s'" , externalCmd )
179
+ cmdArr := strings .Split (externalCmd , " " )
180
+ externalCmdExec := exec .Command (cmdArr [0 ])
181
+ externalCmdExec .Env = append (os .Environ (), cfg .Envs ... )
182
+ externalCmdExec .Args = cmdArr
183
+ externalCmdExec .Stdout = os .Stdout
184
+ externalCmdExec .Stderr = os .Stderr
185
+ err := externalCmdExec .Run ()
186
+ if err != nil {
187
+ panic (err )
188
+ }
189
+ }
190
+ cmd = exec .Command (appname , cfg .CmdArgs ... )
178
191
cmd .Stdout = os .Stdout
179
192
cmd .Stderr = os .Stderr
180
- cmd .Args = append ([]string {appname }, cfg .CmdArgs ... )
181
193
cmd .Env = append (os .Environ (), cfg .Envs ... )
182
- log .Infof ("Run %s " , strings .Join (cmd .Args , " " ))
194
+ log .Infof ("Run '%s' " , strings .Join (cmd .Args , " " ))
183
195
go func () {
184
196
_ = cmd .Run ()
185
197
}()
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package main
2
2
3
3
import "fmt"
4
4
5
- const version = "1.3 "
5
+ const version = "1.4 "
6
6
7
7
func printVersion () {
8
8
fmt .Println (version )
You can’t perform that action at this time.
0 commit comments