Method: ExecuteLocal#my_execute

Defined in:
lib/teuton/case/execute/execute_local.rb

#my_execute(cmd, encoding = "UTF-8") ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/teuton/case/execute/execute_local.rb', line 15

def my_execute(cmd, encoding = "UTF-8")
  return {exitcode: 0, content: ""} if Project.debug?

  begin
    text, status = Open3.capture2e(cmd)
    exitcode = status.exitstatus
  rescue => e
    verbose Rainbow("!").green
    text = e.to_s
    exitcode = 1
  end
  content = encode_and_split(encoding, text)
  {exitcode: exitcode, content: content}
end