Skip to content

Commit

Permalink
improve command docker for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed May 12, 2022
1 parent 6d0b4fa commit c40a4d8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/gf/internal/cmd/cmd_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"runtime"

"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/v2/frame/g"
Expand Down Expand Up @@ -93,8 +94,8 @@ func (c cDocker) Index(ctx context.Context, in cDockerInput) (out *cDockerOutput
}

// Shell executing.
if gfile.Exists(in.Shell) {
if err = gproc.ShellRun(gfile.GetContents(in.Shell)); err != nil {
if in.Shell != "" && gfile.Exists(in.Shell) {
if err = c.exeDockerShell(in.Shell); err != nil {
return
}
}
Expand Down Expand Up @@ -150,3 +151,11 @@ func (c cDocker) Index(ctx context.Context, in cDockerInput) (out *cDockerOutput
}
return
}

func (c cDocker) exeDockerShell(shellFilePath string) error {
if gfile.ExtName(shellFilePath) == "sh" && runtime.GOOS == "windows" {
mlog.Debugf(`ignore shell file "%s", as it cannot be run on windows system`, shellFilePath)
return nil
}
return gproc.ShellRun(gfile.GetContents(shellFilePath))
}

0 comments on commit c40a4d8

Please sign in to comment.