|
Lines 20-36
use File::Slurp qw( read_file );
Link Here
|
| 20 |
use File::Find; |
20 |
use File::Find; |
| 21 |
use FindBin(); |
21 |
use FindBin(); |
| 22 |
use Data::Dumper qw( Dumper ); |
22 |
use Data::Dumper qw( Dumper ); |
| 23 |
use Test::More tests => 1; |
23 |
use Test::More tests => 2; |
| 24 |
|
24 |
|
| 25 |
my $vue_dir = "$FindBin::Bin/../koha-tmpl/intranet-tmpl/prog/js/vue"; |
25 |
my $vue_dir = "$FindBin::Bin/../koha-tmpl/intranet-tmpl/prog/js/vue"; |
| 26 |
|
26 |
|
| 27 |
my @files; |
27 |
my @files; |
| 28 |
sub wanted { |
28 |
sub wanted_vue { |
| 29 |
my $name = $File::Find::name; |
29 |
my $name = $File::Find::name; |
| 30 |
push @files, $name |
30 |
push @files, $name |
| 31 |
if $name =~ /\.vue$/; |
31 |
if $name =~ /\.vue$/; |
| 32 |
} |
32 |
} |
| 33 |
find({ wanted => \&wanted, no_chdir => 1 }, $vue_dir); |
33 |
find({ wanted => \&wanted_vue, no_chdir => 1 }, $vue_dir); |
| 34 |
|
34 |
|
| 35 |
my @not_tidy; |
35 |
my @not_tidy; |
| 36 |
foreach my $filepath (@files) { |
36 |
foreach my $filepath (@files) { |
|
Lines 42-45
foreach my $filepath (@files) {
Link Here
|
| 42 |
} |
42 |
} |
| 43 |
} |
43 |
} |
| 44 |
|
44 |
|
| 45 |
is(scalar(@not_tidy), 0, 'No vue file should be messy') or diag Dumper \@not_tidy; |
45 |
is(scalar(@not_tidy), 0, 'No .vue file should be messy') or diag Dumper \@not_tidy; |
|
|
46 |
|
| 47 |
@files = (); |
| 48 |
sub wanted_js_ts { |
| 49 |
my $name = $File::Find::name; |
| 50 |
push @files, $name |
| 51 |
if ( $name =~ /\.js$/ |
| 52 |
|| $name =~ /\.ts$/ ) |
| 53 |
&& $name !~ m{koha-tmpl/intranet-tmpl/prog/js/vue/dist}; # Exclude dist |
| 54 |
} |
| 55 |
find({ wanted => \&wanted_js_ts, no_chdir => 1 }, $vue_dir); |
| 56 |
|
| 57 |
@not_tidy = (); |
| 58 |
foreach my $filepath (@files) { |
| 59 |
chomp $filepath; |
| 60 |
my $tidy = qx{yarn --silent run prettier --trailing-comma es5 --arrow-parens avoid $filepath}; |
| 61 |
my $content = read_file $filepath; |
| 62 |
if ( $content ne $tidy ) { |
| 63 |
push @not_tidy, $filepath; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
is(scalar(@not_tidy), 0, 'No js file from vue directory should be messy') or diag Dumper \@not_tidy; |
| 46 |
- |
|
|