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 25, 2024
1 parent 1b90419 commit 81b8469
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions prettier/shell-glob-files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
open my $git, "-|", "git ls-files -z";
{
local $/ = "\0";
my $sought_extensions_re = join '|', (map { s/([\\{}.\[\]])/\\$1/g; $_ } keys %supported_extensions);
while (my $file_with_path = <$git>) {
chomp $file_with_path;
my ($path, $file, $ext) = ($file_with_path =~ m<(.*/|)(?:([^/.]+)(\.[^/]+))$>);
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;
$interesting_paths{$path} = 1;
}
Expand Down

0 comments on commit 81b8469

Please sign in to comment.