Skip to content

Commit

Permalink
Use stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelofabri committed Feb 3, 2017
1 parent f5370c7 commit 5ce8ed7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 12 additions & 4 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@ end

# Run OSSCheck if there were app changes
if has_app_changes || has_dangerfile_changes
def non_empty_lines(path)
File.read(path).split(/\n+/).reject(&:empty?)
def non_empty_lines(lines)
lines.split(/\n+/).reject(&:empty?)
end

def parse_line(line)
line.split(':', 2).last.strip
end

lines = non_empty_lines(`script/oss-check`)
lines.each do |line|
lines = nil
Open3.popen3('script/oss-check') do |_, stdout, stderr, _|
while char = stdout.getc
print char
end

lines = stderr.read.chomp
end

non_empty_lines(lines).each do |line|
if line.start_with? 'Message:'
message parse_line(line)
elsif line.start_with? 'Warning:'
Expand Down
7 changes: 4 additions & 3 deletions script/oss-check
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ require 'fileutils'
require 'open3'

def message(str)
puts('Message: ' + str)
$stderr.puts('Message: ' + str)
end

def warn(str)
puts('Warning: ' + str)
$stderr.puts('Warning: ' + str)
end

def fail(str)
puts('Error: ' + str)
$stderr.puts('Error: ' + str)
exit
end

$stdout.sync = true
repo_clean = `git status --porcelain`.empty?

unless repo_clean
Expand Down

0 comments on commit 5ce8ed7

Please sign in to comment.