Koha/xt/vue_tidy.t
Jonathan Druart e16003e19e
Bug 32130: Add a test to ensure vue files will be kept tidy
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-11 08:49:30 -03:00

45 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use File::Slurp qw( read_file );
use File::Find;
use FindBin();
use Data::Dumper qw( Dumper );
use Test::More tests => 1;
my $vue_dir = "$FindBin::Bin/../koha-tmpl/intranet-tmpl/prog/js/vue";
my @files;
sub wanted {
my $name = $File::Find::name;
push @files, $name
if $name =~ /\.vue$/;
}
find({ wanted => \&wanted, no_chdir => 1 }, $vue_dir);
my @not_tidy;
foreach my $filepath (@files) {
chomp $filepath;
my $tidy = qx{yarn --silent run prettier --trailing-comma es5 --semi false --arrow-parens avoid $filepath};
my $content = read_file $filepath;
if ( $content ne $tidy ) {
push @not_tidy, $filepath;
}
}
is(scalar(@not_tidy), 0, 'No vue file should be messy') or diag Dumper \@not_tidy;