Subject: | ShipIt::Step::UploadCPAN doesn't work if 'which' doesn't silently fail |
on Mac OS X (Tiger), which(1) doesn't fail silently:
$ which foobar
no foobar in /usr/local/bin /usr/bin ...
so ShipIt::Step::UploadCPAN gets that error message in $self->{exe} and thus the upload fails.
Attached is a version of UploadCPAN.pm which uses the more portable File::Which.
Subject: | UploadCPAN.pm |
package ShipIt::Step::UploadCPAN;
use warnings;
use strict;
use File::Which;
use ShipIt::Util qw(bool_prompt);
use base 'ShipIt::Step';
sub init {
my ($self, $conf) = @_;
my $exe;
$exe = which('cpan-upload-http') || which('cpan-upload');
die "neither cpan-upload-http nor cpan-upload found\n" unless $exe;
$self->{exe} = $exe;
}
sub run {
my ($self, $state) = @_;
my $distfile = $state->distfile;
die "No distfile was created!" unless $distfile;
die "distfile $distfile no longer exists!" unless -e $distfile;
if ($state->dry_run) {
warn "*** DRY RUN, not uploading to CPAN!\n";
return;
}
return unless bool_prompt("Upload to CPAN?", "y");
system($self->{exe}, $distfile) and die "Upload failed.\n";
}
1;