summaryrefslogtreecommitdiff
path: root/lib/gitlab/popen.rb
blob: f2cfd8073e3c8b602d056330073fdef37b963542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Gitlab
  module Popen
    def popen(cmd, path)
      vars = { "PWD" => path }
      options = { :chdir => path }

      @cmd_output = ""
      @cmd_status = 0
      Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr|
        @cmd_status = wait_thr.value.exitstatus
        @cmd_output << stdout.read
        @cmd_output << stderr.read
      end

      return @cmd_output, @cmd_status
    end
  end
end