实时运行
(command string, rootDir string)
| 37 | |
| 38 | // 实时运行 |
| 39 | func (eo *execOperation) Realtime(command string, rootDir string) error { |
| 40 | |
| 41 | var execCommand *exec.Cmd |
| 42 | switch runtime.GOOS { |
| 43 | case "windows": |
| 44 | execCommand = exec.Command("powershell", "/c", command) |
| 45 | case "darwin": |
| 46 | execCommand = exec.Command("bash", "-c", command) |
| 47 | case "linux": |
| 48 | execCommand = exec.Command("bash", "-c", command) |
| 49 | } |
| 50 | if rootDir != "" { |
| 51 | execCommand.Dir = rootDir |
| 52 | } |
| 53 | |
| 54 | currentWorkingDir := "" |
| 55 | if execCommand.Dir != "" { |
| 56 | currentWorkingDir = fmt.Sprintf("> %v", execCommand.Dir) |
| 57 | } |
| 58 | SmartIDELog.Debug(fmt.Sprintf("local realtime (%v) exec %v -> %v ", |
| 59 | runtime.GOOS, currentWorkingDir, command)) |
| 60 | |
| 61 | execCommand.Stdout = os.Stdout |
| 62 | execCommand.Stderr = os.Stderr |
| 63 | err := execCommand.Run() |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | // 一次性返回结果 |
| 72 | func (eo *execOperation) CombinedOutput(command string, rootDir string) (string, error) { |
no test coverage detected