[carton] 198/472: Simplified cpanfile detection
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to branch master
in repository carton.
commit bd9b889e171c9f0cb4544255f15f4ec71ceb82a2
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date: Thu May 30 16:31:10 2013 +0900
Simplified cpanfile detection
---
lib/Carton/CLI.pm | 32 ++++++++++++++++----------------
xt/cli/no_cpanfile.t | 12 ++++++++++++
2 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index ce84b1d..abfe155 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -143,13 +143,13 @@ sub cmd_bundle {
mirror_file => $self->mirror_file,
);
- my $cpanfile = $self->has_cpanfile;
+ my $cpanfile = $self->find_cpanfile;
- if ($cpanfile && $lock) {
+ if ($lock) {
$self->print("Bundling modules using $cpanfile\n");
$self->carton->download_from_cpanfile($cpanfile, $local_mirror);
} else {
- $self->error("Can't locate cpanfile and lock file. Run carton install first\n");
+ $self->error("Can't locate carton.lock file. Run carton install first\n");
}
$self->printf("Complete! Modules were bundled into %s\n", $local_mirror, SUCCESS);
@@ -174,11 +174,9 @@ sub cmd_install {
( $self->{use_local_mirror} && -d $local_mirror ? (mirror => $local_mirror) : () ),
);
- my $cpanfile = $self->has_cpanfile;
+ my $cpanfile = $self->find_cpanfile;
- if (!$cpanfile) {
- $self->error("Can't locate cpanfile.\n");
- } elsif ($self->{deployment}) {
+ if ($self->{deployment}) {
$self->print("Installing modules using $cpanfile (deployment mode)\n");
$self->carton->install_from_cpanfile($cpanfile);
} else {
@@ -195,13 +193,6 @@ sub mirror_file {
return $self->work_file("02packages.details.txt");
}
-sub has_cpanfile {
- my $self = shift;
-
- return 'cpanfile' if -e 'cpanfile';
- return;
-}
-
sub cmd_show {
my($self, @args) = @_;
@@ -230,8 +221,7 @@ sub cmd_list {
sub cmd_check {
my($self, @args) = @_;
- my $file = $self->has_cpanfile
- or $self->error("Can't find a build file: nothing to check.\n");
+ my $file = $self->find_cpanfile;
$self->parse_options(\@args, "p|path=s", sub { $self->carton->{path} = $_[1] });
@@ -290,6 +280,16 @@ sub cmd_exec {
$system ? system(@args) : exec(@args);
}
+sub find_cpanfile {
+ my $self = shift;
+
+ if (-e 'cpanfile') {
+ return 'cpanfile';
+ } else {
+ $self->error("Can't locate cpanfile\n");
+ }
+}
+
sub find_lock {
my $self = shift;
diff --git a/xt/cli/no_cpanfile.t b/xt/cli/no_cpanfile.t
new file mode 100644
index 0000000..0f6ff82
--- /dev/null
+++ b/xt/cli/no_cpanfile.t
@@ -0,0 +1,12 @@
+use strict;
+use Test::More;
+use xt::CLI;
+
+{
+ my $app = cli();
+ $app->run("install");
+ like $app->output, qr/Can't locate cpanfile/;
+}
+
+done_testing;
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git
More information about the Pkg-perl-cvs-commits
mailing list