Module: Bake::GitHub::Pages::Shell

Defined in:
lib/bake/github/pages/shell.rb

Instance Method Summary collapse

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, **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) ⇒ Object



61
62
63
64
65
# File 'lib/bake/github/pages/shell.rb', line 61

def readlines(*arguments, **options)
	execute(*arguments, **options) 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, **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