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.
7 8 9 10 11 12 13 |
# File 'lib/ember_cli/runner.rb', line 7 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
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ember_cli/runner.rb', line 15 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
27 28 29 30 31 32 33 |
# File 'lib/ember_cli/runner.rb', line 27 def run!(command) run(command).tap do |status| unless status.success? fail BuildError, "`#{command}` failed with status #{status.exitstatus}" end end end |