(service string, cmd string)
| 2631 | } |
| 2632 | |
| 2633 | func (app *DdevApp) ExecOnHostOrService(service string, cmd string) error { |
| 2634 | var err error |
| 2635 | // Handle case on host |
| 2636 | if service == "host" { |
| 2637 | cwd, _ := os.Getwd() |
| 2638 | err = os.Chdir(app.GetAppRoot()) |
| 2639 | if err != nil { |
| 2640 | return fmt.Errorf("unable to GetAppRoot: %v", err) |
| 2641 | } |
| 2642 | bashPath := "bash" |
| 2643 | if nodeps.IsWindows() { |
| 2644 | bashPath = util.FindBashPath() |
| 2645 | if bashPath == "" { |
| 2646 | return fmt.Errorf("unable to find bash.exe on Windows") |
| 2647 | } |
| 2648 | } |
| 2649 | |
| 2650 | args := []string{ |
| 2651 | "-c", |
| 2652 | cmd, |
| 2653 | } |
| 2654 | |
| 2655 | _ = app.DockerEnv() |
| 2656 | err = exec.RunInteractiveCommand(bashPath, args) |
| 2657 | _ = os.Chdir(cwd) |
| 2658 | } else { // handle case in container |
| 2659 | _, _, err = app.Exec( |
| 2660 | &ExecOpts{ |
| 2661 | Service: service, |
| 2662 | Cmd: cmd, |
| 2663 | Tty: isatty.IsTerminal(os.Stdin.Fd()), |
| 2664 | }) |
| 2665 | } |
| 2666 | return err |
| 2667 | } |
| 2668 | |
| 2669 | // Logs returns logs for a site's given container. |
| 2670 | // See docker.LogsOptions for more information about valid tailLines values. |
no test coverage detected