shell support for bash and zsh when running a build

This commit is contained in:
Jan Halfar 2021-02-16 15:28:08 +01:00
parent d37b952b4e
commit ada2c6025e

View File

@ -332,13 +332,22 @@ func (sq Squadron) Build(s Service) (string, error) {
if s.Build.Command == "" { if s.Build.Command == "" {
return "", ErrBuildNotConfigured return "", ErrBuildNotConfigured
} }
args := []string{}
args := strings.Split(s.Build.Command, " ") shell := "/bin/bash"
if args[0] == "docker" && s.Build.Image != "" && s.Build.Tag != "" { for _, envVarName := range []string{"SHELL", "SQUADRON_SHELL"} {
image := fmt.Sprintf("%v:%v", s.Build.Image, s.Build.Tag) if os.Getenv(envVarName) != "" {
args = append(strings.Split(s.Build.Command, " "), "-t", image) shell = os.Getenv(envVarName)
}
} }
return util.NewCommand(sq.l, args[0]).Args(args[1:]...).Cwd(sq.basePath).Run() switch filepath.Base(shell) {
case "bash":
args = []string{"-c"}
case "zsh":
args = []string{"-c"}
}
args = append(args, s.Build.Command)
return util.NewCommand(sq.l, shell).Args(args...).Cwd(sq.basePath).Run()
} }
func (sq Squadron) Push(s Service) (string, error) { func (sq Squadron) Push(s Service) (string, error) {