Sha256: 8161fd7c6b54658f58e174b99d9f95ed02bb629224d6f899a26052fb33044959

Contents?: true

Size: 729 Bytes

Versions: 4

Compression:

Stored size: 729 Bytes

Contents

require 'io/console'

module GitBundle
  module Shell
    def execute_pipe(*args)
      puts args.map { |arg| "'#{arg}'" }.join(' ') if ENV['DEBUG'] == 'true'

      pipe_out, pipe_in = IO.pipe
      fork do
        system *args, out: pipe_in, err: pipe_in
      end
      pipe_in.close
      pipe_out
    end

    def execute_live(*args)
      execute_pipe(*args).each_line { |line| puts line.chomp }
    end

    def execute(*args, silence_err: false)
      puts args.map { |arg| "'#{arg}'" }.join(' ') if ENV['DEBUG'] == 'true'

      pipe_out, pipe_in = IO.pipe
      pipe_err_in = silence_err ? File::NULL : pipe_in
      system *args, out: pipe_in, err: pipe_err_in
      pipe_in.close
      pipe_out.read
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-bundle-1.0.20 lib/git_bundle/shell.rb
git-bundle-1.0.19 lib/git_bundle/shell.rb
git-bundle-1.0.18 lib/git_bundle/shell.rb
git-bundle-1.0.16 lib/git_bundle/shell.rb