(name string, args ...string)
| 1254 | } |
| 1255 | |
| 1256 | func runCommand(name string, args ...string) (string, string, error) { |
| 1257 | command := exec.Command(name, args...) |
| 1258 | if len(workingDir) > 0 { |
| 1259 | command.Dir = workingDir |
| 1260 | } |
| 1261 | commandString := strings.Join(command.Args, " ") |
| 1262 | say.Debug("Running command <" + commandString + "> passing output through") |
| 1263 | |
| 1264 | stdout, _ := command.StdoutPipe() |
| 1265 | command.Stderr = command.Stdout |
| 1266 | errStart := command.Start() |
| 1267 | if errStart != nil { |
| 1268 | return commandString, "", errStart |
| 1269 | } |
| 1270 | |
| 1271 | output := "" |
| 1272 | |
| 1273 | stdoutscanner := bufio.NewScanner(stdout) |
| 1274 | lineEnded := true |
| 1275 | stdoutscanner.Split(bufio.ScanBytes) |
| 1276 | for stdoutscanner.Scan() { |
| 1277 | character := stdoutscanner.Text() |
| 1278 | if character == "\n" { |
| 1279 | lineEnded = true |
| 1280 | } else { |
| 1281 | if lineEnded { |
| 1282 | say.PrintToConsole(" ") |
| 1283 | lineEnded = false |
| 1284 | } |
| 1285 | } |
| 1286 | say.PrintToConsole(character) |
| 1287 | output += character |
| 1288 | } |
| 1289 | |
| 1290 | errWait := command.Wait() |
| 1291 | if errWait != nil { |
| 1292 | say.Debug(output) |
| 1293 | return commandString, output, errWait |
| 1294 | } |
| 1295 | |
| 1296 | say.Debug(output) |
| 1297 | return commandString, output, nil |
| 1298 | } |
| 1299 | |
| 1300 | func startCommand(name string, args ...string) (string, error) { |
| 1301 | command := exec.Command(name, args...) |
no test coverage detected