module Bake::Gem::Shell

Public Instance Methods

execute(*arguments, **options) { |input| ... } click to toggle source
# File lib/bake/gem/shell.rb, line 41
def execute(*arguments, **options)
        Console.logger.info(self, Console::Event::Spawn.for(*arguments, **options))
        
        IO.pipe do |input, output|
                pid = Process.spawn(*arguments, out: output, **options)
                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) click to toggle source
# File lib/bake/gem/shell.rb, line 60
def readlines(*arguments, **options)
        execute(*arguments, **options) do |output|
                return output.readlines
        end
end
system(*arguments, **options) { || ... } click to toggle source
# File lib/bake/gem/shell.rb, line 26
def system(*arguments, **options)
        Console.logger.info(self, Console::Event::Spawn.for(*arguments, **options))
        
        begin
                pid = Process.spawn(*arguments, **options)
                yield if block_given?
        ensure
                pid, status = Process.wait2(pid) if pid
                
                unless status.success?
                        raise "Failed to execute #{arguments}: #{status}!"
                end
        end
end