Skip to content

Commit

Permalink
Do not match directory that begins with ._, only files. #260
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Oct 19, 2012
1 parent ecb3a36 commit c2b3646
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Plack/Loader/Restarter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use strict;
use warnings;
use parent qw(Plack::Loader);
use Plack::Util;
use File::Basename;
use Try::Tiny;

sub new {
Expand Down Expand Up @@ -46,7 +47,7 @@ sub _kill_child {

sub valid_file {
my($self, $file) = @_;
$file->{path} !~ m![/\\][\._]|\.bak$|~$|_flymake\.p[lm]!;
File::Basename::basename($file->{path}) !~ m!^[\._]|\.bak$|~$|_flymake\.p[lm]!;
}

sub run {
Expand Down
15 changes: 15 additions & 0 deletions t/Plack-Loader/restarter_valid.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use strict;
use Plack::Loader::Restarter;
use Test::More;

my $r = Plack::Loader::Restarter->new;

my @match = qw(Foo.pm foo.t lib/Bar.pm view/index.tt _myapp/foo.psgi /Users/joe/foo/bar.pm);
my @ignore = qw(.xxx Foo.pm~ _flymake.pl foo/.bar.pm /Users/joe/foo.pl~);

ok $r->valid_file({ path => $_ }), "$_ is valid" for @match;
ok !$r->valid_file({ path => $_ }), "$_ should be ignored" for @ignore;

done_testing;


0 comments on commit c2b3646

Please sign in to comment.