Skip to content

Commit

Permalink
allow multiple commands to run on build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Strässle committed Jun 23, 2021
1 parent 39b144a commit 50a8deb
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,37 @@ func failColor(format string, args ...interface{}) string {
func build() bool {
log.Println(okColor("Running build command!"))

args := strings.Split(*flagBuild, " ")
if len(args) == 0 {
// If the user has specified and empty then we are done.
return true
}
commands := strings.Split(*flagBuild, "&&")
success := true
for _, c := range commands {
c = strings.TrimSpace(c)
args := strings.Split(c, " ")
if len(args) == 0 {
// If the user has specified and empty then we are done.
return true
}

cmd := exec.Command(args[0], args[1:]...)
cmd := exec.Command(args[0], args[1:]...)

if *flagBuildDir != "" {
cmd.Dir = *flagBuildDir
} else if len(flagDirectories) > 0 {
cmd.Dir = flagDirectories[0]
}
if *flagBuildDir != "" {
cmd.Dir = *flagBuildDir
} else if len(flagDirectories) > 0 {
cmd.Dir = flagDirectories[0]
}

output, err := cmd.CombinedOutput()
output, err := cmd.CombinedOutput()

if err == nil {
log.Println(okColor("Build ok."))
} else {
log.Println(failColor("Error while building:\n"), failColor(string(output)))
if err == nil {
log.Println(okColor("Build ok."))
} else {
log.Println(failColor("Error while building:\n"), failColor(string(output)))
if success {
success = false
}
}
}

return err == nil
return success
}

func matchesPattern(pattern *regexp.Regexp, file string) bool {
Expand Down

0 comments on commit 50a8deb

Please sign in to comment.