-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.go
53 lines (44 loc) · 908 Bytes
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package command
import (
"fmt"
"os"
"os/exec"
"github.com/TharpHuang/gofar/tools/text"
)
var warningBuild = text.TrimLeft(`
Gofar build: no arguments input.
Use "gofar build [arguments]"
The arguments are:
proto build protobuf files of go
migrate build databases migrateion files of go`)
func BuildFile(jobType string) {
if jobType == "" {
fmt.Println(warningBuild)
return
}
switch jobType {
case "proto":
buildProtoFile()
default:
fmt.Println(warningGen)
}
}
func buildProtoFile() {
cmd, err := script("./real_deploy.sh")
if err != nil {
panic(err)
}
fmt.Println(cmd)
output, err := cmd.CombinedOutput()
if err != nil {
panic(err)
}
fmt.Println(string(output))
}
func script(scrip string) (*exec.Cmd, error) {
shell := "/bin/sh"
if other := os.Getenv("SHELL"); other != "" {
shell = other
}
return exec.Command(shell, "-c", scrip+" generate protogen"), nil
}