Module: Bake::GitHub::Pages::Shell
- Defined in:
- lib/bake/github/pages/shell.rb
Instance Method Summary collapse
- #execute(*arguments, **options) ⇒ Object
- #readlines(*arguments, **options) ⇒ Object
- #system(*arguments, **options) ⇒ Object
Instance Method Details
#execute(*arguments, **options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bake/github/pages/shell.rb', line 42 def execute(*arguments, **) Console.logger.info(self, Console::Event::Spawn.for(*arguments, **)) IO.pipe do |input, output| pid = Process.spawn(*arguments, out: output, **) output.close begin yield input ensure pid, status = Process.wait2(pid) unless status.success? raise "Failed to execute #{arguments}: #{status}!" end end end end |
#readlines(*arguments, **options) ⇒ Object
61 62 63 64 65 |
# File 'lib/bake/github/pages/shell.rb', line 61 def readlines(*arguments, **) execute(*arguments, **) do |output| return output.readlines end end |
#system(*arguments, **options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bake/github/pages/shell.rb', line 27 def system(*arguments, **) Console.logger.info(self, Console::Event::Spawn.for(*arguments, **)) begin pid = Process.spawn(*arguments, **) yield if block_given? ensure pid, status = Process.wait2(pid) if pid unless status.success? raise "Failed to execute #{arguments}: #{status}!" end end end |