Fix slashes when running on Windows (#461)

This commit is contained in:
Cat™ 2021-01-12 06:41:35 +00:00 committed by GitHub
parent 15eaa15a0e
commit 760daebf5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"strings"
"runtime"
"github.com/go-git/go-billy/v5/helper/polyfill"
"github.com/go-git/go-billy/v5/osfs"
@ -333,6 +334,15 @@ func (cr *containerReference) extractGithubEnv(env *map[string]string) common.Ex
func (cr *containerReference) exec(cmd []string, env map[string]string) common.Executor {
return func(ctx context.Context) error {
logger := common.Logger(ctx)
// Fix slashes when running on Windows
if runtime.GOOS == "windows" {
var newCmd []string
for _, v := range cmd {
newCmd = append(newCmd, strings.ReplaceAll(v, `\`, `/`))
}
cmd = newCmd
}
logger.Debugf("Exec command '%s'", cmd)
isTerminal := term.IsTerminal(int(os.Stdout.Fd()))
envList := make([]string, 0)