Stop chdir when finding packlist. Absolutify %INC path in case there's a relative...
[p5sagit/App-FatPacker.git] / lib / App / FatPacker.pm
index 2ae6f3a..c35aa25 100644 (file)
@@ -147,13 +147,14 @@ sub packlists_containing {
   }
   my @search = grep -d $_, map catdir($_, 'auto'), @INC;
   my %pack_rev;
-  my $cwd = cwd;
-  find(sub {
-    return unless $_ eq '.packlist' && -f $_;
-    $pack_rev{$_} = $File::Find::name for lines_of $File::Find::name;
+  find({
+    no_chdir => 1,
+    wanted => sub {
+      return unless /[\\\/]\.packlist$/ && -f $_;
+      $pack_rev{$_} = $File::Find::name for lines_of $File::Find::name;
+    },
   }, @search);
-  chdir($cwd) or die "Couldn't chdir back to ${cwd} after find: $!";
-  my %found; @found{map +($pack_rev{$INC{$_}}||()), @targets} = ();
+  my %found; @found{map +($pack_rev{Cwd::abs_path($INC{$_})}||()), @targets} = ();
   sort keys %found;
 }