Skip to content

Commit 8db6c4e

Browse files
committed
names updated and shell-scripts updated
1 parent ba2b52d commit 8db6c4e

File tree

7 files changed

+61
-30
lines changed

7 files changed

+61
-30
lines changed

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) error {
10-
return watch(fileordirPath, hOS)
9+
func WatchFiles(fileordirPath string, hOS string, name string) error {
10+
return watch(fileordirPath, hOS, name)
1111
}
1212

13-
func watch(fileordirPath string, hOS string) error {
13+
func watch(fileordirPath string, hOS string, name 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) error {
2121
return err
2222
}
2323
if stat.Size() != initialStat.Size() || stat.ModTime() != initialStat.ModTime() {
24-
killProcess.KillProcess(hOS)
24+
killProcess.KillProcess(hOS, name)
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) {
11+
func ExecMOD(hOS string, name string) {
1212
jsonFile, err := os.Open("project.json")
1313
errors.ErrorHandle(err)
1414
defer jsonFile.Close()
@@ -21,7 +21,7 @@ func ExecMOD(hOS string) {
2121
err = os.Setenv(pr.Vars[i].Key, pr.Vars[i].Value)
2222
errors.TMPerrorHandle(err)
2323
}
24-
execMOD(hOS)
24+
execMOD(hOS, name)
2525
}
2626

2727
func ExecFile(filepath string) {

execs/executablesPv.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
"os/exec"
77
)
88

9-
func execMOD(hOS string) {
9+
func execMOD(hOS string, name string) {
1010
if hOS == "windows" {
11-
cmd := exec.Command("app-godemon-app-godemon-tmp-generated.exe")
11+
cmd := exec.Command("app-godemon-app-godemon-tmp-generated" + "-" + name + ".exe")
1212
cmd.Stdout = os.Stdout
1313
cmd.Stderr = os.Stderr
1414
err := cmd.Run()
1515
errors.ErrorHandle(err)
1616
} else {
17-
cmd := exec.Command("./app-godemon-app-godemon-tmp-generated")
17+
cmd := exec.Command("./app-godemon-app-godemon-tmp-generated" + "-" + name)
1818
cmd.Stdout = os.Stdout
1919
cmd.Stderr = os.Stderr
2020
err := cmd.Run()

godemon-installer.sh

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
11
#!/bin/sh
22

3-
wget https://github.com/nProgrammer/godemon/releases/download/2.6.1/godemon
3+
wget https://github.com/nProgrammer/godemon/releases/download/2.6.3/godemon
44

55
printf "What do you want to do? \n1. Install Godemon \n2. Update Godemon \n"
6+
printf "\nAnswer: "
67
read OPTION
8+
printf "\nDo you want to do this: \n1. Global \n2. Local \n"
9+
printf "\nAnswer: "
10+
read GL
711

812
if [ "$OPTION" = "1" ]
913
then
10-
sudo mv -r godemon /bin/godemon
11-
sudo chmod 777 /bin/godemon
14+
if [ "$GL" = "2" ]
15+
then
16+
mkdir ~/.godemon
17+
mkdir ~/.godemon/bin/
18+
sudo mv -r godemon ~/.godemon/bin/
19+
sudo chmod 777 ~/.godemon/bin/godemon
20+
elif [ "$GL" = "1" ]
21+
then
22+
sudo mkdir /usr/local/.godemon
23+
sudo mkdir /usr/local/.godemon/bin/
24+
sudo mv -r godemon /usr/local/.godemon/bin/
25+
sudo chmod 777 /usr/local/.godemon/bin/godemon
26+
fi
1227
elif [ "$OPTION" = "2" ]
1328
then
14-
sudo rm -r /bin/godemon
15-
sudo mv godemon /bin/godemon
16-
sudo chmod 777 /bin/godemon
29+
if [ "$GL" = "2" ]
30+
then
31+
sudo mv -r godemon ~/.godemon/bin/
32+
sudo chmod 777 ~/.godemon/bin/godemon
33+
elif [ "$GL" = "1" ]
34+
then
35+
sudo mv -r godemon /usr/local/.godemon/bin/
36+
sudo chmod 777 /usr/local/.godemon/bin/godemon
37+
fi
1738
fi
1839

19-
printf "\n Everything done \n"
40+
sudo rm -r godemon
41+
42+
printf "\n Everything done \n"
43+
if [ "$OPTION" = "1" ]
44+
then
45+
if [ "$GL" = "2" ]
46+
then
47+
printf "\n Now add to .bashrc following line: export PATH=\$PATH:~/.godemon/bin"
48+
elif [ "$GL" = "1" ]
49+
then
50+
printf "\n Now add to .bashrc following line: export PATH=\$PATH:/usr/local/.godemon/bin"
51+
fi
52+
fi

killProcess/kill.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import (
66
"os/exec"
77
)
88

9-
func killCMDgen(hOS string) *exec.Cmd {
9+
func killCMDgen(hOS string, name string) *exec.Cmd {
1010
var cmd *exec.Cmd
1111
if hOS == "windows" {
12-
cmd = exec.Command("taskkill", "/IM", "app-godemon-app-godemon-tmp-generated.exe", "/F")
12+
cmd = exec.Command("taskkill", "/IM", "app-godemon-app-godemon-tmp-generated"+"-"+name+".exe", "/F")
1313
} else {
14-
cmd = exec.Command("killall", "-9", "app-godemon-app-godemon-tmp-generated")
14+
cmd = exec.Command("killall", "-9", "app-godemon-app-godemon-tmp-generated"+"-"+name)
1515
}
1616
return cmd
1717
}
1818

19-
func KillProcess(hOS string) {
20-
cmd := killCMDgen(hOS)
19+
func KillProcess(hOS string, name string) {
20+
cmd := killCMDgen(hOS, name)
2121
cmd.Stdout = os.Stdout
2222
cmd.Stderr = os.Stderr
2323
err := cmd.Run()

main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// TODO - prepare the code to manage all errors that user can do
2-
31
package main
42

53
import (
@@ -18,7 +16,7 @@ import (
1816
func main() {
1917
hostInfo := [2]string{build.Default.GOOS, build.Default.GOARCH}
2018
color.Cyan("Godemon starting...")
21-
version := "2.6.2"
19+
version := "2.6.3"
2220
doneChan := make(chan bool)
2321
filepath, modOrFile, cnf, command, help, init, name, oso, arch := cliTools.LoadCMD("", "")
2422
filepath, modOrFile = controllers.ProgramStarting(&cnf, filepath, modOrFile, command, help, version, init, name, oso, arch, hostInfo[0])
@@ -27,20 +25,20 @@ func main() {
2725
defer func() {
2826
doneChan <- true
2927
}()
30-
err := controllers.WatchFiles(filepath, hostInfo[0])
28+
err := controllers.WatchFiles(filepath, hostInfo[0], name)
3129
errors.ErrorHandle(err)
3230
fmt.Println("File has been changed")
3331
if modOrFile == "mod" {
3432
err = os.Chdir(filepath)
3533
errors.ErrorHandle(err)
3634
cliTools.TimeLog()
3735
var cmd *exec.Cmd
38-
cmd = models.CMDhotReload(hostInfo)
36+
cmd = models.CMDhotReload(hostInfo, name)
3937
cmd.Stdout = os.Stdout
4038
cmd.Stderr = os.Stderr
4139
err = cmd.Run()
4240
errors.ErrorHandle(err)
43-
go execs.ExecMOD(hostInfo[0])
41+
go execs.ExecMOD(hostInfo[0], name)
4442
} else if modOrFile == "file" {
4543
cliTools.TimeLog()
4644
go execs.ExecFile(filepath)

models/hotReload.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package models
22

33
import "os/exec"
44

5-
func CMDhotReload(hostInfo [2]string) *exec.Cmd {
5+
func CMDhotReload(hostInfo [2]string, name string) *exec.Cmd {
66
if hostInfo[0] != "windows" {
7-
cmd := exec.Command("go", "build", "-o", "app-godemon-app-godemon-tmp-generated")
7+
cmd := exec.Command("go", "build", "-o", "app-godemon-app-godemon-tmp-generated"+"-"+name)
88
return cmd
99
} else {
10-
cmd := exec.Command("go", "build", "-o", "app-godemon-app-godemon-tmp-generated.exe")
10+
cmd := exec.Command("go", "build", "-o", "app-godemon-app-godemon-tmp-generated"+"-"+name+".exe")
1111
return cmd
1212
}
1313
}

0 commit comments

Comments
 (0)