Skip to content
This repository
Browse code

Merge pull request #29 from nihen/support_multiple_mirror

support specify multiple mirror
  • Loading branch information...
commit 9fbc3b048c3ae6a70e6fa919c38598be93b090d5 2 parents 788034f + 8a11818
Tatsuhiko Miyagawa authored May 10, 2012
10  lib/Carton.pm
@@ -134,11 +134,17 @@ sub install_conservative {
134 134
 
135 135
     my $mirror = $self->{mirror} || $DefaultMirror;
136 136
 
  137
+    my $is_default_mirror = 0;
  138
+    if ( !ref $mirror ) {
  139
+        $is_default_mirror = $mirror eq $DefaultMirror ? 1 : 0;
  140
+        $mirror = [split /,/, $mirror];
  141
+    }
  142
+
137 143
     $self->run_cpanm(
138  
-        "--mirror", $mirror,
  144
+        (map { ("--mirror", $_) } @{$mirror}),
139 145
         "--mirror", "http://backpan.perl.org/", # fallback
140 146
         "--skip-satisfied",
141  
-        ( $mirror ne $DefaultMirror ? "--mirror-only" : () ),
  147
+        ( $is_default_mirror ? () : "--mirror-only" ),
142 148
         ( $self->lock ? ("--mirror-index", $self->{mirror_file}) : () ),
143 149
         ( $cascade ? "--cascade-search" : () ),
144 150
         @$modules,
34  xt/cli/mirror_multi.t
... ...
@@ -0,0 +1,34 @@
  1
+use strict;
  2
+use Test::More;
  3
+use xt::CLI;
  4
+use Cwd;
  5
+
  6
+my $cwd = Cwd::cwd();
  7
+
  8
+{
  9
+    # split string
  10
+    my $app = cli();
  11
+
  12
+    $app->carton->{mirror} = "$cwd/xt/mirror,http://cpan.metacpan.org/";
  13
+    $app->run("install", "PSGI");
  14
+
  15
+    $app->run("list");
  16
+    like $app->output, qr/^PSGI-/;
  17
+}
  18
+
  19
+{
  20
+    # ARRAY ref
  21
+    my $app = cli();
  22
+
  23
+    $app->carton->{mirror} = ["$cwd/xt/mirror", "http://cpan.metacpan.org/"];
  24
+    $app->run("install", "PSGI");
  25
+
  26
+    $app->run("list");
  27
+    like $app->output, qr/^PSGI-/;
  28
+}
  29
+
  30
+
  31
+done_testing;
  32
+
  33
+
  34
+

0 notes on commit 9fbc3b0

Please sign in to comment.
Something went wrong with that request. Please try again.