Sha256: 23877e48852c58ec8e29f077c2fcb658698312eb0b7a301a315134a5d6cf38d7
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
require 'stringio' module Builderator module Util ## # Extend the functionality of Thor::Actions::run ## module Shell def execute(command, config = {}) return unless behavior == :invoke destination = relative_to_original_destination_root(destination_root, false) desc = "#{command} from #{destination.inspect}" if config[:with] desc = "#{File.basename(config[:with].to_s)} #{desc}" command = "#{config[:with]} #{command}" end say_status :run, desc, config.fetch(:verbose, true) BufferTee.new($stdout).tap do |t| IO.popen(command, :err => [:child, :out]).each { |l| t.write(l) } end unless options[:pretend] end ## # Buffer an IO stream and forward to another IO instance ## class BufferTee < StringIO attr_reader :output def initialize(out, *args) super(*args) @output = out end def write(data) super(data) output.write(data) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems