lib/teuton/case_manager/utils.rb in teuton-2.5.0 vs lib/teuton/case_manager/utils.rb in teuton-2.6.0
- old
+ new
@@ -1,7 +1,9 @@
require_relative "../application"
require "fileutils"
+require "open3"
+require "rainbow"
module Utils
def ensure_dir(dirname)
# Create the directory if it dosn't exist.
unless Dir.exist?(dirname)
@@ -31,14 +33,17 @@
def my_execute(cmd, encoding = "UTF-8")
return {exitstatus: 0, content: ""} if Application.instance.debug
begin
- text = `#{cmd}`
- exitstatus = $CHILD_STATUS.exitstatus
+ # text = `#{cmd}`
+ # exitstatus = $CHILD_STATUS.exitstatus
+ text, status = Open3.capture2e(cmd)
+ exitstatus = status.exitstatus
rescue => e
- verbose "!"
- puts("[ERROR] #{e}: Local exec: #{cmd}")
+ verbose Rainbow("!").green
+ text = e.to_s
+ exitstatus = 1
end
content = encode_and_split(encoding, text)
{exitstatus: exitstatus, content: content}
end