Permalink
Browse files

maybe support .meta/{distvname}/install.json (miyagawa++)

  • Loading branch information...
1 parent dd88e0b commit 6102b7edde4067f88f1fd0114087215e5098eb16 @xaicron committed Oct 12, 2011
Showing with 22 additions and 1 deletion.
  1. +2 −0 Makefile.PL
  2. +20 −1 lib/App/pmuninstall.pm
View
@@ -11,6 +11,8 @@ WriteMakefile(
'HTTP::Tiny' => 0.012,
'Module::CoreList' => 0,
'version' => 0,
+ 'JSON' => 0,
+ 'File::Slurp' => 0,
},
LICENSE => 'perl',
EXE_FILES => [ 'bin/pm-uninstall' ],
View
@@ -11,6 +11,8 @@ use version;
use HTTP::Tiny;
use Term::ANSIColor qw(colored);
use Cwd ();
+use JSON qw(decode_json);
+use File::Slurp qw(slurp);
our $VERSION = "0.24";
@@ -174,12 +176,29 @@ sub find_packlist {
my $meta = YAML::Load($yaml);
my $info = CPAN::DistnameInfo->new($meta->{distfile});
- if (my $pl = $self->locate_pack($info->dist)) {
+ my $name = $self->find_meta($info->distvname) || $info->dist;
+ if (my $pl = $self->locate_pack($name)) {
$self->puts("-> Found $pl") if $self->{verbose};
return ($pl, $info->dist, $info->distvname);
}
}
+sub find_meta {
+ my ($self, $distvname) = @_;
+
+ my $name;
+ for my $lib (@{$self->{inc}}) {
+ next unless $lib =~ /$Config{archname}/;
+ my $install_json = "$lib/.meta/$distvname/install.json";
+ next unless -f $install_json && -r _;
+ my $data = decode_json slurp $install_json;
+ $name = $data->{name};
+ $self->puts("-> Found .meta/$distvname/install.josn");
+ last;
+ }
+ return $name;
+}
+
sub locate_pack {
my ($self, $dist) = @_;
$dist =~ s!-!/!g;

0 comments on commit 6102b7e

Please sign in to comment.