Module: Jets::Util::Sh
- Included in:
- Code, Code::Copy::Base, Code::Stager
- Defined in:
- lib/jets/util/sh.rb
Instance Method Summary collapse
- #capture(command) ⇒ Object
- #quiet_sh(command, options = {}) ⇒ Object
- #sh(command, options = {}) ⇒ Object
Instance Method Details
#capture(command) ⇒ Object
32 33 34 35 36 |
# File 'lib/jets/util/sh.rb', line 32 def capture(command) out = `#{command}`.strip raise Jets::Error.new("Command failed: #{command}\n#{caller(1..1).first}") unless $?.success? out end |
#quiet_sh(command, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/jets/util/sh.rb', line 27 def quiet_sh(command, = {}) = .merge(quiet: true) unless ENV["JETS_DEBUG"] sh(command, ) end |
#sh(command, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jets/util/sh.rb', line 3 def sh(command, = {}) quiet = [:quiet] on_fail = [:on_fail] || :raise puts "=> #{command}" unless quiet system(command) success = $?.success? case on_fail when :raise raise Jets::Error.new("Command failed: #{command}\n#{caller(1..1).first}") unless success when :exit unless success if quiet abort("Command failed: #{command}\n") else abort("Command failed: #{command}\n#{caller.join("\n")}") end end end success end |