Class: FastlaneCore::FastlanePty

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/fastlane_pty.rb

Class Method Summary collapse

Class Method Details

.spawn(command, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'fastlane_core/lib/fastlane_core/fastlane_pty.rb', line 6

def self.spawn(command, &block)
  require 'pty'
  PTY.spawn(command) do |command_stdout, command_stdin, pid|
    block.call(command_stdout, command_stdin, pid)
  end
rescue LoadError
  require 'open3'
  Open3.popen2e(command) do |command_stdin, command_stdout, p| # note the inversion
    yield(command_stdout, command_stdin, p.value.pid)

    command_stdin.close
    command_stdout.close
    p.value.exitstatus
  end
end