Skip to content

Commit

Permalink
errors can be in either channel
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Jan 25, 2024
1 parent 4342c7b commit 5fd941a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
20 changes: 20 additions & 0 deletions extract-errors.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env perl
my $new_source = "$ENV{source}.new";
open my $source_in, "<", $ENV{source};
open my $source_out, ">", $new_source;
open my $errors, ">>", $ENV{errors};
my $found_error=0;
while (<$source_in>) {
if ($found_error) {
print $errors $_;
} elsif (/^error:/) {
$found_error=1;
print $errors $_;
} else {
print $source_out $_;
}
}
close $source_in;
close $source_out;
close $errors;
rename $new_source, $ENV{source};
25 changes: 2 additions & 23 deletions run-scalafmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,8 @@ report() {

errors=$(mktemp)

if grep -q '^error:' "$output"; then
output="$output" errors="$errors" perl -e '
my $new_output = "$ENV{output}.new";
open my $output_in, "<", $ENV{output};
open my $output_out, ">", $new_output;
open my $errors, ">", $ENV{errors};
my $found_error=0;
while (<$output_in>) {
if ($found_error) {
print $errors $_;
} elsif (/^error:/) {
$found_error=1;
print $errors $_;
} else {
print $output_out $_;
}
}
close $output_in;
close $output_out;
close $errors;
rename $new_output, $ENV{output};
'
fi
source="$output" errors="$errors" extract-errors.pl
source="$warnings" errors="$errors" extract-errors.pl

(
echo "# scalafmt failed ($result)"
Expand Down

0 comments on commit 5fd941a

Please sign in to comment.