Method: Teapot::Git::Commands.run

Defined in:
lib/teapot/repository.rb

.run(*args, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/teapot/repository.rb', line 28

def self.run(*args, &block)
	options = Hash === args.last ? args.pop : {}
	
	args = args.flatten.collect &:to_s
	
	puts args.join(' ').color(:blue) + " in #{options[:chdir] || Dir.getwd}"
	
	pid = Process.spawn(*args, options, &block)
	_, result = Process.wait2(pid)
	
	if result.exitstatus == 0
		true
	else
		raise CommandError.new("Non-zero exit status: #{result} while running #{args.join(' ')}!")
	end
end