From e07d54d1daaa6209025a55c841689080f271bd44 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sun, 23 Jan 2022 14:40:59 +0800 Subject: [PATCH] fix: fix exec windows command test failed --- system/os.go | 3 +++ system/os_test.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/system/os.go b/system/os.go index f9a290e..91a1cb9 100644 --- a/system/os.go +++ b/system/os.go @@ -56,6 +56,9 @@ func ExecCommand(command string) (stdout, stderr string, err error) { var errout bytes.Buffer cmd := exec.Command("/bin/bash", "-c", command) + if IsWindows() { + cmd = exec.Command("cmd") + } cmd.Stdout = &out cmd.Stderr = &errout err = cmd.Run() diff --git a/system/os_test.go b/system/os_test.go index 1d5ac1f..d70813f 100644 --- a/system/os_test.go +++ b/system/os_test.go @@ -56,5 +56,7 @@ func TestExecCommand(t *testing.T) { t.Logf("error: %v\n", err) } - assert.IsNotNil(err) + if !IsWindows() { + assert.IsNotNil(err) + } }