Skip to content

Commit 8b10a82

Browse files
committed
code updated, shell-script updated
1 parent a4ece26 commit 8b10a82

File tree

8 files changed

+30
-33
lines changed

8 files changed

+30
-33
lines changed

cliTools/loadFlags.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@ import (
44
"flag"
55
)
66

7-
func LoadCMD(filepath string, modOrFile string) (string, string, string, string, *bool, bool, string, string, string, bool) {
7+
func LoadCMD(filepath string, modOrFile string) (string, string, string, string, *bool, bool, string, string, string) {
88
var filepathP *string
99
var modOrFileP *string
1010
cnfP := flag.String("cnf", "", "a string")
1111
filepathP = flag.String("path", "", "a string")
1212
commandP := flag.String("command", "", "a string")
1313
helpP := flag.Bool("help", false, "a bool")
14-
logsP := flag.Bool("logs", false, "a bool")
1514
initP := flag.Bool("init", false, "a bool")
1615
nameP := flag.String("name", "", "a string")
1716
osP := flag.String("os", "", "a string")
1817
archP := flag.String("arch", "", "a string")
1918
modOrFileP = flag.String("modOrFile", "", "a string")
2019
flag.Parse()
2120
cnf := *cnfP
22-
logs := *logsP
2321
filepath = *filepathP
2422
init := *initP
2523
name := *nameP
2624
os := *osP
2725
arch := *archP
2826
command := *commandP
2927
modOrFile = *modOrFileP
30-
return filepath, modOrFile, cnf, command, helpP, init, name, os, arch, logs
28+
return filepath, modOrFile, cnf, command, helpP, init, name, os, arch
3129
}

controllers/watch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
"time"
77
)
88

9-
func WatchFiles(fileordirPath string, hOS string, name string) error {
10-
return watch(fileordirPath, hOS, name)
9+
func WatchFiles(fileordirPath string, hOS string) error {
10+
return watch(fileordirPath, hOS)
1111
}
1212

13-
func watch(fileordirPath string, hOS string, name string) error {
13+
func watch(fileordirPath string, hOS string) error {
1414
initialStat, err := os.Stat(fileordirPath)
1515
if err != nil {
1616
return err
@@ -21,7 +21,7 @@ func watch(fileordirPath string, hOS string, name string) error {
2121
return err
2222
}
2323
if stat.Size() != initialStat.Size() || stat.ModTime() != initialStat.ModTime() {
24-
killProcess.KillProcess(hOS, name)
24+
killProcess.KillProcess(hOS)
2525
break
2626
}
2727
time.Sleep(1 * time.Second)

execs/executables.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os"
99
)
1010

11-
func ExecMOD(hOS string, name string, logs bool) {
11+
func ExecMOD(hOS string) {
1212
jsonFile, err := os.Open("project.json")
1313
errors.ErrorHandle(err)
1414
defer jsonFile.Close()
@@ -21,7 +21,7 @@ func ExecMOD(hOS string, name string, logs bool) {
2121
err = os.Setenv(pr.Vars[i].Key, pr.Vars[i].Value)
2222
errors.TMPerrorHandle(err)
2323
}
24-
execMOD(hOS, name, logs)
24+
execMOD(hOS)
2525
}
2626

2727
func ExecFile(filepath string) {

execs/executablesPv.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,20 @@ package execs
22

33
import (
44
"godemon/errors"
5+
"godemon/prepareProject"
56
"os"
67
"os/exec"
78
)
89

9-
func execMOD(hOS string, name string, logs bool) {
10+
func execMOD(hOS string) {
11+
name := prepareProject.LoadProjectInfo().Name
1012
if hOS == "windows" {
1113
cmd := exec.Command("app-godemon-app-godemon-tmp-generated" + "-" + name + ".exe")
1214
cmd.Stdout = os.Stdout
1315
cmd.Stderr = os.Stderr
1416
err := cmd.Run()
1517
errors.ErrorHandle(err)
1618
} else {
17-
if logs == true {
18-
logFile := name + "_logs.txt"
19-
cmd := exec.Command("./app-godemon-app-godemon-tmp-generated" + "-" + name + "2>&1" + "|" + "tee" + logFile)
20-
cmd.Stdout = os.Stdout
21-
cmd.Stderr = os.Stderr
22-
err := cmd.Run()
23-
errors.ErrorHandle(err)
24-
return
25-
}
2619
cmd := exec.Command("./app-godemon-app-godemon-tmp-generated" + "-" + name)
2720
cmd.Stdout = os.Stdout
2821
cmd.Stderr = os.Stderr

godemon-installer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ printf "\nDo you want to do this: \n1. Global \n2. Local \n"
99
printf "\nAnswer: "
1010
read GL
1111

12-
wget https://github.com/nProgrammer/godemon/releases/download/2.6.4/godemon
12+
wget https://github.com/nProgrammer/godemon/releases/download/2.7.0/godemon
1313

1414
if [ "$OPTION" = "1" ]
1515
then
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
package models
1+
package hotReload
22

3-
import "os/exec"
3+
import (
4+
"godemon/prepareProject"
5+
"os/exec"
6+
)
47

5-
func CMDhotReload(hostInfo [2]string, name string) *exec.Cmd {
8+
func CMDhotReload(hostInfo [2]string) *exec.Cmd {
9+
name := prepareProject.LoadProjectInfo().Name
610
if hostInfo[0] != "windows" {
711
cmd := exec.Command("go", "build", "-o", "app-godemon-app-godemon-tmp-generated"+"-"+name)
812
return cmd

killProcess/kill.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package killProcess
22

33
import (
44
"godemon/errors"
5+
"godemon/prepareProject"
56
"os"
67
"os/exec"
78
)
89

9-
func killCMDgen(hOS string, name string) *exec.Cmd {
10+
func killCMDgen(hOS string) *exec.Cmd {
11+
name := prepareProject.LoadProjectInfo().Name
1012
var cmd *exec.Cmd
1113
if hOS == "windows" {
1214
cmd = exec.Command("taskkill", "/IM", "app-godemon-app-godemon-tmp-generated"+"-"+name+".exe", "/F")
@@ -16,8 +18,8 @@ func killCMDgen(hOS string, name string) *exec.Cmd {
1618
return cmd
1719
}
1820

19-
func KillProcess(hOS string, name string) {
20-
cmd := killCMDgen(hOS, name)
21+
func KillProcess(hOS string) {
22+
cmd := killCMDgen(hOS)
2123
cmd.Stdout = os.Stdout
2224
cmd.Stderr = os.Stderr
2325
err := cmd.Run()

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ import (
88
"godemon/controllers"
99
"godemon/errors"
1010
"godemon/execs"
11-
"godemon/models"
11+
"godemon/hotReload"
1212
"os"
1313
"os/exec"
1414
)
1515

1616
func main() {
1717
hostInfo := [2]string{build.Default.GOOS, build.Default.GOARCH}
1818
color.Cyan("Godemon starting...")
19-
version := "2.6.4"
19+
version := "2.7.0"
2020
doneChan := make(chan bool)
21-
filepath, modOrFile, cnf, command, help, init, name, oso, arch, logs := cliTools.LoadCMD("", "")
21+
filepath, modOrFile, cnf, command, help, init, name, oso, arch := cliTools.LoadCMD("", "")
2222
filepath, modOrFile = controllers.ProgramStarting(&cnf, filepath, modOrFile, command, help, version, init, name, oso, arch, hostInfo[0])
2323
for true {
2424
go func(doneChan chan bool) {
2525
defer func() {
2626
doneChan <- true
2727
}()
28-
err := controllers.WatchFiles(filepath, hostInfo[0], name)
28+
err := controllers.WatchFiles(filepath, hostInfo[0])
2929
errors.ErrorHandle(err)
3030
fmt.Println("File has been changed")
3131
if modOrFile == "mod" {
3232
err = os.Chdir(filepath)
3333
errors.ErrorHandle(err)
3434
cliTools.TimeLog()
3535
var cmd *exec.Cmd
36-
cmd = models.CMDhotReload(hostInfo, name)
36+
cmd = hotReload.CMDhotReload(hostInfo)
3737
cmd.Stdout = os.Stdout
3838
cmd.Stderr = os.Stderr
3939
err = cmd.Run()
4040
errors.ErrorHandle(err)
41-
go execs.ExecMOD(hostInfo[0], name, logs)
41+
go execs.ExecMOD(hostInfo[0])
4242
} else if modOrFile == "file" {
4343
cliTools.TimeLog()
4444
go execs.ExecFile(filepath)

0 commit comments

Comments
 (0)