class Hula::CommandRunner
Attributes
environment[R]
Public Class Methods
new(environment: ENV)
click to toggle source
# File lib/hula/command_runner.rb, line 17 def initialize(environment: ENV) @environment = environment end
Public Instance Methods
run(command, allow_failure: false)
click to toggle source
# 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? message = "Command failed! - #{command}\n\n#{stdout_and_stderr}\n\nexit status: #{status.exitstatus}" fail CommandFailedError, message end stdout_and_stderr rescue => e raise CommandFailedError, e end