Module: Gitlab::Git::Popen
- Included in:
- Repository
- Defined in:
- lib/gitlab_git/popen.rb
Instance Method Summary collapse
Instance Method Details
#popen(cmd, path) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab_git/popen.rb', line 6 def popen(cmd, path) unless cmd.is_a?(Array) raise "System commands must be given as an array of strings" end vars = { "PWD" => path } = { chdir: path } @cmd_output = "" @cmd_status = 0 Open3.popen3(vars, *cmd, ) do |stdin, stdout, stderr, wait_thr| @cmd_output << stdout.read @cmd_output << stderr.read @cmd_status = wait_thr.value.exitstatus end [@cmd_output, @cmd_status] end |