Permalink
Browse files

Added an option to use cpanminus

  • Loading branch information...
miyagawa committed Feb 19, 2010
1 parent 4c76c1e commit ff4f25b2a8232f674878f87f12b0a78c39a56c23
Showing with 19 additions and 7 deletions.
  1. +3 −0 Changes
  2. +16 −7 lib/App/CPAN/Fresh.pm
View
@@ -1,5 +1,8 @@
Revision history for Perl extension App::CPAN::Fresh
+0.08 Fri Feb 19 15:19:26 PST 2010
+ - Added --minus|-m option to use cpanminus http://bit.ly/cpanm
+
0.07 Fri Sep 11 16:15:25 JST 2009
- Added -d option to install devel version of the module.
View
@@ -7,7 +7,6 @@ our $VERSION = '0.07';
use base qw(App::Cmd::Simple);
use Carp;
-use CPAN::Inject;
use Time::Piece;
use File::Temp;
use JSON;
@@ -23,6 +22,7 @@ sub opt_spec {
[ "test|t", "test the dist" ],
[ "force|f", "force install" ],
[ "devel|d", "install even if it's a devel release" ],
+ [ "minus|m", "use cpanminus" ],
[ "help|h", "displays usage info" ],
);
}
@@ -76,11 +76,15 @@ sub handle {
$method = "test" if $opt->{test};
if (@install) {
- require CPAN;
- if ($opt->{force}) {
- CPAN::Shell->force($method, @install);
+ if ($opt->{minus}) {
+ system "cpanm", ($opt->{force} ? "-f" : ()), @install;
} else {
- CPAN::Shell->$method(@install);
+ require CPAN;
+ if ($opt->{force}) {
+ CPAN::Shell->force($method, @install);
+ } else {
+ CPAN::Shell->$method(@install);
+ }
}
}
}
@@ -98,7 +102,7 @@ sub inject {
warn "$info->{dist}-$info->{version} found: No -d option, skipping\n";
return;
}
- return $self->do_inject($info);
+ return $self->do_inject($info, $opt);
}
}
}
@@ -107,7 +111,11 @@ sub inject {
}
sub do_inject {
- my($self, $info) = @_;
+ my($self, $info, $opt) = @_;
+
+ if ($opt->{minus}) {
+ return $info->{url};
+ }
my $dir = File::Temp::tempdir(CLEANUP => 1);
my $local = "$dir/$info->{dist}-$info->{version}.tar.gz";
@@ -118,6 +126,7 @@ sub do_inject {
croak "Fetching $info->{url} failed: ", $res->status_line;
}
+ require CPAN::Inject;
CPAN::Inject->from_cpan_config->add(file => $local);
}

0 comments on commit ff4f25b

Please sign in to comment.