Class: Overcommit::Subprocess
- Inherits:
-
Object
- Object
- Overcommit::Subprocess
- Defined in:
- lib/overcommit/subprocess.rb
Overview
Manages execution of a child process, collecting the exit status and standard out/error output.
Defined Under Namespace
Classes: Result
Class Method Summary collapse
-
.spawn(args) ⇒ Object
Spawns a new process using the given array of arguments (the first element is the command).
Class Method Details
.spawn(args) ⇒ Object
Spawns a new process using the given array of arguments (the first element is the command).
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/overcommit/subprocess.rb', line 17 def self.spawn(args) process = ChildProcess.build(*args) err = ::Tempfile.new('err') err.sync = true out = ::Tempfile.new('out') out.sync = true process.io.stderr = err process.io.stdout = out process.start process.wait err.rewind out.rewind Result.new(process.exit_code, err.read, out.read) end |