Skip to content

Commit 6a400f7

Browse files
committed
code updated
1 parent 856d9cb commit 6a400f7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

controllers/functions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ func ProgramStarting(cnf *string, filepath string, modOrFile string, command str
5252
modOrFile = commands.Commands[i].Option
5353
}
5454
}
55+
} else if *cnf == "deploy" {
56+
jsonFile, err := os.Open("project.json")
57+
ErrorHandle(err)
58+
defer jsonFile.Close()
59+
byteValue, err := ioutil.ReadAll(jsonFile)
60+
ErrorHandle(err)
61+
var pr models.Project
62+
json.Unmarshal(byteValue, &pr)
63+
goos := "GOOS=" + pr.OS
64+
arch := "GOARCH=" + pr.Arch
65+
name := pr.Name
66+
os.Chdir(pr.Path)
67+
cmd := exec.Command("env", goos, arch, "go", "build", "-o", name)
68+
cmd.Stdout = os.Stdout
69+
cmd.Stderr = os.Stderr
70+
cmd.Run()
71+
os.Exit(1)
5572
} else if *help == true {
5673
fmt.Printf("Godemon %v: \n 1. -cnf <- in this flag put info about what do you want to do - if use cmd option use -cnf=cmd, if config file use -cnf=cnf \n 2. -path <- path to file/directory \n 3. -modOrFile <- are you using modules or one file \n 4. -command <- binded command in config file \n", version)
5774
os.Exit(1)

models/cnf.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ type Command struct {
99
type Commands struct {
1010
Commands []Command `json:"commands"`
1111
}
12+
13+
type Project struct {
14+
Name string `json:"name"`
15+
Arch string `json:"arch"`
16+
OS string `json:"os"`
17+
Path string `json:"path"`
18+
}

0 commit comments

Comments
 (0)