Skip to content

Commit 65c0569

Browse files
committed
fix: fixes processOutput to use different writers instead of os.Stdout
1 parent 83fb82a commit 65c0569

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

pkg/runfile/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func processOutput(writer io.Writer, reader io.Reader, prefix *string) {
6969
if err != nil {
7070
// logger.Info("stdout", "msg", string(msg[:n]), "err", err)
7171
if errors.Is(err, io.EOF) {
72-
os.Stdout.Write(msg[:n])
72+
writer.Write(msg[:n])
7373
return
7474
}
7575
}
@@ -80,7 +80,7 @@ func processOutput(writer io.Writer, reader io.Reader, prefix *string) {
8080

8181
if prevByte == '\n' && prefix != nil {
8282
// os.Stdout.WriteString(fmt.Sprintf("HERE... msg: '%s'", msg[:n]))
83-
os.Stdout.WriteString(*prefix)
83+
writer.Write([]byte(*prefix))
8484
}
8585

8686
writer.Write(msg[:n])

pkg/runfile/task-parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ func parseCommand(rf *Runfile, command any) (*CommandJson, *Error) {
191191
return nil, CommandInvalid.WithErr(fmt.Errorf("key: 'run', must be specified when setting command in json format")).WithMetadata("command", command)
192192
}
193193

194+
if cj.If == nil {
195+
cj.If = fn.New(true)
196+
}
197+
194198
if _, ok := rf.Tasks[cj.Run]; !ok {
195199
return nil, CommandInvalid.WithErr(fmt.Errorf("run target, not found")).WithMetadata("command", command, "run-target", cj.Run)
196200
}

pkg/runfile/task.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ type Task struct {
4646
// List of commands to be executed in given shell (default: sh)
4747
// can take multiple forms
4848
// - simple string
49-
// - a json object with key `run`, signifying other tasks to run
49+
// - a json object with key
50+
// `run`, signifying other tasks to run
51+
// `if`, condition when to run this server
5052
Commands []any `json:"cmd"`
5153
}
5254

5355
type CommandJson struct {
5456
Command string
5557
Run string `json:"run"`
58+
If *bool `json:"if"`
5659
}

0 commit comments

Comments
 (0)