Class: Hula::CommandRunner
- Inherits:
-
Object
- Object
- Hula::CommandRunner
- Defined in:
- lib/hula/command_runner.rb
Instance Method Summary collapse
-
#initialize(environment: ENV) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #run(command, allow_failure: false) ⇒ Object
Constructor Details
#initialize(environment: ENV) ⇒ CommandRunner
Returns a new instance of CommandRunner.
17 18 19 |
# File 'lib/hula/command_runner.rb', line 17 def initialize(environment: ENV) @environment = environment end |
Instance Method Details
#run(command, allow_failure: false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hula/command_runner.rb', line 21 def run(command, allow_failure: false) stdout_and_stderr, status = Open3.capture2e(environment, command) if !allow_failure && !status.success? = "Command failed! - #{command}\n\n#{stdout_and_stderr}\n\nexit status: #{status.exitstatus}" fail CommandFailedError, end stdout_and_stderr rescue => e raise CommandFailedError, e end |