Skip to content

Commit

Permalink
For #18 - look for all cpanfile upward and add lib to @inc
Browse files Browse the repository at this point in the history
  • Loading branch information
hkoba committed Jul 9, 2021
1 parent d7aa7fe commit 858c649
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/App/perlminlint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ sub upward_first_file_from (&@) {
}
}

sub upward_find_all_file_from (&@) {
my ($code, $startFn, $lookfor) = @_;
my @dirs = MY->splitdir(MY->rel2abs($startFn));
pop @dirs;
local $_;
my @result;
while (@dirs) {
-e (my $fn = MY->catdir(@dirs, $lookfor))
or next;
if (my $result = $code->($_ = $fn, MY->catdir(@dirs))) {
push @result, $result
}
} continue {
pop @dirs;
}
@result;
}

sub add_lib_to_inc_for {
(my MY $self, my $fn) = @_;

Expand All @@ -143,6 +161,14 @@ sub add_lib_to_inc_for {
1;
}
} $fn, 'lib';

upward_find_all_file_from {
my ($cpanfile, $dir) = @_;
my $libdir = "$dir/lib";
if (-d $libdir) {
$adder->($libdir);
}
} $fn, 'cpanfile';
}

sub find_and_load_config_from {
Expand Down

0 comments on commit 858c649

Please sign in to comment.