Skip to content

Commit 1ef9cf8

Browse files
committed
Get zeuz node dir from a single function
1 parent 5345ef8 commit 1ef9cf8

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Apps/node_runner/main.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
)
1717

1818
var (
19-
version = "dev"
20-
branch = flag.String("branch", "", "Branch to download (defaults to tagged version)")
19+
version = "dev"
20+
branch = flag.String("branch", "", "Branch to download (defaults to tagged version)")
2121
cleanFlag = flag.Bool("clean", false, "Remove ZeuZ Node directory and $HOME/.zeuz and exit")
2222
)
2323

@@ -131,19 +131,21 @@ func getZeuZNodeURL() string {
131131
return "https://github.com/AutomationSolutionz/Zeuz_Python_Node/archive/refs/heads/dev.zip"
132132
}
133133

134-
func getZeuZPostfix() string {
134+
func getZeuZNodeDir() string {
135+
selectedVersion := ""
135136
if *branch != "" {
136-
return *branch
137+
selectedVersion = *branch
137138
}
138139
if version != "dev" && !strings.HasPrefix(version, "dev-") {
139-
return version
140+
selectedVersion = version
140141
}
141-
return "dev"
142+
143+
return fmt.Sprintf("ZeuZ_Node-%s", selectedVersion)
142144
}
143145

144146
// setupZeuzNode downloads and extracts the ZeuZ Node repository if not already present
145147
func setupZeuzNode() error {
146-
zeuzDir := fmt.Sprintf("Zeuz_Node-%s", getZeuZPostfix())
148+
zeuzDir := getZeuZNodeDir()
147149
// Check if ZeuZ Node directory already exists and contains files
148150
if info, err := os.Stat(zeuzDir); err == nil && info.IsDir() {
149151
// Check if directory is not empty
@@ -272,7 +274,7 @@ func main() {
272274

273275
fmt.Printf("✅ ZeuZ Node %s\n", version)
274276

275-
zeuzDir := fmt.Sprintf("Zeuz_Python_Node-%s", getZeuZPostfix())
277+
zeuzDir := getZeuZNodeDir()
276278

277279
if *cleanFlag {
278280
var removedAny bool

0 commit comments

Comments
 (0)