Skip to content

Commit

Permalink
Match suffixes of multisuffix files
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Apr 24, 2024
1 parent 55c6423 commit b858e05
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions prettier/shell-glob-files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
open my $git, "-|", "git ls-files -z";
{
local $/ = "\0";
my $sought_extensions_re = '';
while (my $file_with_path = <$git>) {
chomp $file_with_path;
my ($path, $file, $ext) = ($file_with_path =~ m<(.*/|)(?:([^/.]+)(\.[^/]+))$>);
if ($sought_extensions_re eq '') {
my @sought_extensions = keys %supported_extensions;
@sought_extensions = map { s/([\\{}.\[\]])/\\$1/g; $_ } @sought_extensions;
$sought_extensions_re = join '|', @sought_extensions;
last if $sought_extensions_re eq '';
}
my ($path, $file) = ($file_with_path =~ m<(.*/|)([^/]+)$>);
$path = "." if $path eq "";
$path =~ s</$><>;
next unless defined $supported_extensions{$ext};
next unless $file =~ /($sought_extensions_re)$/;
my $ext = $1;
$found_extensions{$ext} = 1;
delete $supported_extensions{$ext};
$interesting_paths{$path} = 1;
}
}
Expand Down

0 comments on commit b858e05

Please sign in to comment.