Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/check-formats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@ jobs:
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
shopt -s extglob globstar nullglob
perltidy --pro=./.perltidyrc -b -bext='/' ./**/*.p[lm] ./**/*.t ./**/*.at && git diff --exit-code

perl_files=(./**/*.p[lm] ./**/*.t ./**/*.at)

for f in bin/* bin/dev_scripts/*; do
if [[ -f "$f" && ! "$f" == *.* ]]; then
if head -n 1 "$f" | grep -qE '^#!.*(\bperl\b)'; then
perl_files+=("$f")
fi
fi
done

if [ ${#perl_files[@]} -gt 0 ]; then
perltidy --pro=./.perltidyrc -b -bext='/' "${perl_files[@]}"
git diff --exit-code
fi

prettier:
name: Check JavaScript, style, and HTML file formatting with prettier
Expand Down
Empty file modified bin/addadmin
100755 → 100644
Empty file.
14 changes: 12 additions & 2 deletions bin/dev_scripts/run-perltidy.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ =head1 OPTIONS

use Perl::Tidy;
use File::Find qw(find);
use Mojo::File qw(curfile);
use Mojo::File qw(curfile path);

my $webwork_root = curfile->dirname->dirname->dirname;

Expand Down Expand Up @@ -91,7 +91,17 @@ =head1 OPTIONS
return;
}

return unless $path =~ /\.p[lm]$/ || $path =~ /\.t$/ || $path =~ /\.at$/;
my $isPerlScript = 0;
if (($dir =~ /\/bin$/ || $dir =~ /\/bin\/dev_scripts$/)
&& $path !~ /\.p[lm]$/
&& -f $path
&& (my $fh = path($path)->open('<')))
{
$isPerlScript = <$fh> =~ /^#!.*\bperl\b/;
$fh->close;
}

return unless $path =~ /\.p[lm]$/ || $path =~ /\.t$/ || $path =~ /\.at$/ || $isPerlScript;

say "Tidying file: $path" if $verbose;

Expand Down