Class: EmberCli::Runner
- Inherits:
-
Object
- Object
- EmberCli::Runner
- Defined in:
- lib/ember_cli/runner.rb
Instance Method Summary collapse
-
#initialize(out:, err:, env: {}, options: {}) ⇒ Runner
constructor
A new instance of Runner.
- #run(command) ⇒ Object
- #run!(command) ⇒ Object
Constructor Details
#initialize(out:, err:, env: {}, options: {}) ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 9 10 11 |
# File 'lib/ember_cli/runner.rb', line 5 def initialize(out:, err:, env: {}, options: {}) @env = env @output_streams = Array(out) @error_streams = Array(err) @options = @threads = [] end |
Instance Method Details
#run(command) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ember_cli/runner.rb', line 13 def run(command) Open3.popen3(env, command, ) do |stdin, stdout, stderr, process| stdin.close threads << redirect_stream_in_thread(stdout, write_to: output_streams) threads << redirect_stream_in_thread(stderr, write_to: error_streams) threads.each(&:join) process.value end end |
#run!(command) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ember_cli/runner.rb', line 25 def run!(command) run(command).tap do |status| unless status.success? exit status.exitstatus end end end |