MCPcopy Create free account
hub / github.com/UiPath/uipathcli / ExecuteAndWait

Method ExecuteAndWait

plugin/studio/uipcli.go:47–78  ·  view source on GitHub ↗
(args ...string)

Source from the content-addressed store, hash-verified

45}
46
47func (c *Uipcli) ExecuteAndWait(args ...string) (int, string, error) {
48 cmd, err := c.Execute(args...)
49 if err != nil {
50 return 1, "", err
51 }
52 stdout, err := cmd.StdoutPipe()
53 if err != nil {
54 return 1, "", fmt.Errorf("Could not run command: %w", err)
55 }
56 defer func() { _ = stdout.Close() }()
57 stderr, err := cmd.StderrPipe()
58 if err != nil {
59 return 1, "", fmt.Errorf("Could not run command: %w", err)
60 }
61 defer func() { _ = stderr.Close() }()
62 err = cmd.Start()
63 if err != nil {
64 return 1, "", fmt.Errorf("Could not run command: %w", err)
65 }
66
67 stderrOutputBuilder := new(strings.Builder)
68 stderrReader := io.TeeReader(stderr, stderrOutputBuilder)
69
70 var wg sync.WaitGroup
71 wg.Add(3)
72 go c.readOutput(stdout, &wg)
73 go c.readOutput(stderrReader, &wg)
74 go c.wait(cmd, &wg)
75 wg.Wait()
76
77 return cmd.ExitCode(), stderrOutputBuilder.String(), nil
78}
79
80func (c *Uipcli) wait(cmd process.ExecCmd, wg *sync.WaitGroup) {
81 defer wg.Done()

Callers 4

executeMethod · 0.95
executeMethod · 0.95
executeMethod · 0.95
executeMethod · 0.80

Calls 11

ExecuteMethod · 0.95
readOutputMethod · 0.95
waitMethod · 0.95
CloseMethod · 0.80
AddMethod · 0.80
StringMethod · 0.80
StdoutPipeMethod · 0.65
StderrPipeMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
ExitCodeMethod · 0.65

Tested by

no test coverage detected