summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-17 13:28:08 -0700
committerTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-17 13:28:08 -0700
commitbd30e7cb853dd4c526abefcf7fc2a65e28e03793 (patch)
tree83a4ff628581c689ac6607fb6109521c023e1fff
parent4271dc65c4ef75bad562db60c6ebee07105e65b4 (diff)
downloadcarton-bd30e7cb853dd4c526abefcf7fc2a65e28e03793.tar.gz
only warn (and eat) -Ilib when it's right after exec. Fix #97
-rw-r--r--lib/Carton/CLI.pm11
-rw-r--r--xt/cli/exec.t17
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index c9d6574..bd129d5 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -355,7 +355,16 @@ sub cmd_exec {
# allows -Ilib
@args = map { /^(-[I])(.+)/ ? ($1,$2) : $_ } @args;
- $self->parse_options_pass_through(\@args, 'I=s@', sub { die "exec -Ilib is deprecated.\n" });
+ while (@args) {
+ if ($args[0] eq '-I') {
+ warn "exec -Ilib is deprecated. Just run the following command with -I.\n";
+ splice(@args, 0, 2);
+ } else {
+ last;
+ }
+ }
+
+ $self->parse_options_pass_through(\@args); # to handle --
unless (@args) {
$self->error("carton exec needs a command to run.\n");
diff --git a/xt/cli/exec.t b/xt/cli/exec.t
index f1487af..af0bfd4 100644
--- a/xt/cli/exec.t
+++ b/xt/cli/exec.t
@@ -55,5 +55,22 @@ EOF
like $app->stdout, qr/Mojolicious \(4\.01/;
};
+subtest 'carton exec perl -Ilib', sub {
+ my $app = cli();
+ $app->write_cpanfile('');
+ $app->run("install");
+
+ $app->dir->child("lib")->mkpath;
+ $app->dir->child("lib/FooBarBaz.pm")->spew("package FooBarBaz; 1");
+
+ $app->run("exec", "perl", "-Ilib", "-e", 'use FooBarBaz; print "foo"');
+ like $app->stdout, qr/foo/;
+ unlike $app->stderr, qr/exec -Ilib is deprecated/;
+
+ $app->run("exec", "-Ilib", "perl", "-e", 'print "foo"');
+ like $app->stdout, qr/foo/;
+ like $app->stderr, qr/exec -Ilib is deprecated/;
+};
+
done_testing;