From b497b53d950dda75825f2ccacc277c1a17bf2cc9 Mon Sep 17 00:00:00 2001 From: zc Date: Mon, 11 Mar 2024 20:11:01 +0800 Subject: [PATCH] fix host worker run when step name contains spaces --- core/worker/hooks/host/host.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/worker/hooks/host/host.go b/core/worker/hooks/host/host.go index 16e93f9..c471f57 100644 --- a/core/worker/hooks/host/host.go +++ b/core/worker/hooks/host/host.go @@ -20,6 +20,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "github.com/zc2638/wslog" @@ -49,7 +50,8 @@ func (h *host) Begin(ctx context.Context, spec *worker.Workflow) error { args = step.Shell[1:] } cmdData := shell.Script(step.Command) - fp := filepath.Join(scriptPath, step.Name+shell.Suffix) + stepName := strings.ReplaceAll(step.Name, " ", "_") + fp := filepath.Join(scriptPath, stepName+shell.Suffix) if err := os.WriteFile(fp, []byte(cmdData), os.ModePerm); err != nil { log.Error("cannot write file", "error", err) return err