25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/Wiki2Go/Install/make_repository.rb', line 25
def self.popen(cmd, mode="r", expected_exit=0, &proc)
@@logger.info "Executing command in '#{Dir.getwd}': '#{cmd}'" if @@logger
out = Tempfile.new('cvsout')
out.close
ret = IO.popen(cmd + " 2>> #{out.path}", mode) do |io|
proc.call(io)
end
log = IO::readlines(out.path).join($/).strip
if !log.nil? && log.length > 0 then
@@logger.warn(log) if @@logger
end
out.close!
exit_code = $? >> 8
raise "Command\n'#{cmd}'\nfailed with code #{exit_code} in\n#{Dir.pwd}\nExpected exit code: #{expected_exit}" if exit_code != expected_exit
ret
end
|