lib/buildbox/command.rb in buildbox-0.0.2 vs lib/buildbox/command.rb in buildbox-0.0.3
- old
+ new
@@ -10,12 +10,12 @@
end
def run(command)
Buildbox.logger.debug(command)
- output = ""
read_io, write_io, pid = nil
+ result = Buildbox::Result.new(command)
begin
dir = File.expand_path(@path)
# spawn the process in a pseudo terminal so colors out outputted
@@ -31,13 +31,13 @@
if fds
# should have some data to read
begin
chunk = read_io.read_nonblock(10240)
if block_given?
- yield chunk
+ yield result, chunk
end
- output += chunk
+ result.output += chunk
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
# do select again
rescue EOFError, Errno::EIO # EOFError from OSX, EIO is raised by ubuntu
break
end
@@ -47,12 +47,13 @@
read_io.close
Process.waitpid(pid)
# output may be invalid UTF-8, as it is produced by the build command.
- output = Buildbox::UTF8.clean(output)
+ result.finished = true
+ result.exit_status = $?.exitstatus
- Buildbox::Result.new(output.chomp, $?.exitstatus)
+ result
end
def run!(command)
result = run(command)