Skip to content

Commit aad2460

Browse files
committed
authordeps: expand some code to be easier to read
1 parent 3776ae0 commit aad2460

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

Diff for: lib/Dist/Zilla/Util/AuthorDeps.pm

+32-18
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,38 @@ sub extract_author_deps {
107107
if ($missing) {
108108
require Module::Runtime;
109109

110-
@packages =
111-
grep {
112-
$_ eq 'perl'
113-
? ! ($vermap->{perl} && eval "use $vermap->{perl}; 1")
114-
: do {
115-
my $m = $_;
116-
! eval {
117-
local @INC = @INC; push @INC, "$root";
118-
# This will die if module is missing
119-
Module::Runtime::require_module($m);
120-
my $v = $vermap->{$m};
121-
# This will die if VERSION is too low
122-
!$v || $m->VERSION($v);
123-
# Success!
124-
1
125-
}
126-
}
127-
} @packages;
110+
my @new_packages;
111+
PACKAGE: for my $package (@packages) {
112+
if ($package eq 'perl') {
113+
# This is weird, perl can never really be a prereq to fulfill but...
114+
# it was like this. -- rjbs, 2024-06-02
115+
if ($vermap->{perl} && ! eval "use $vermap->{perl}; 1") {
116+
push @new_packages, 'perl';
117+
}
118+
119+
next PACKAGE;
120+
}
121+
122+
my $ok = eval {
123+
local @INC = (@INC, "$root");
124+
125+
# This will die if module is missing
126+
Module::Runtime::require_module($package);
127+
my $v = $vermap->{$package};
128+
129+
# This will die if VERSION is too low
130+
!$v || $package->VERSION($v);
131+
132+
# Success!
133+
1;
134+
};
135+
136+
unless ($ok) {
137+
push @new_packages, $package;
138+
}
139+
}
140+
141+
@packages = @new_packages;
128142
}
129143

130144
# Now that we have a sorted list of packages, use that to build an array of

0 commit comments

Comments
 (0)