From: Tomas Doran Date: Sun, 12 Feb 2012 00:22:54 +0000 (+0000) Subject: Support not having a lib directory X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0843df4544eee56722893bdb5ada7e7f2fb47c3b;p=p5sagit%2FApp-FatPacker.git Support not having a lib directory --- diff --git a/Changes b/Changes index 19b004d..ed4c8a9 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ + - Don't break if there is only a single script to be fatpacked, + without ther being a lib/ directory present. + - Add repsoitory metadata to META.YML 0.9.6 2011-01-18 diff --git a/lib/App/FatPacker.pm b/lib/App/FatPacker.pm index 62a1612..f32459e 100644 --- a/lib/App/FatPacker.pm +++ b/lib/App/FatPacker.pm @@ -153,7 +153,7 @@ sub script_command_file { my ($self, $args) = @_; my $file = shift @$args; my $cwd = cwd; - my @dirs = map rel2abs($_, $cwd), ('lib','fatlib'); + my @dirs = grep { -d $_ } map rel2abs($_, $cwd), ('lib','fatlib'); my %files; foreach my $dir (@dirs) { find(sub { diff --git a/t/pack.t b/t/pack.t deleted file mode 100644 index 4d98b0b..0000000 --- a/t/pack.t +++ /dev/null @@ -1,36 +0,0 @@ -#!perl -use strict; -use warnings FATAL => 'all'; -use Test::More qw(no_plan); -use File::Basename; -use File::Copy; -use File::Path; -use File::Temp; - -BEGIN { use_ok "App::FatPacker", "" } - -my $tempdir = File::Temp->newdir; -mkpath([<$tempdir/{lib,fatlib}/t/mod>]); - -for() { - copy $_, "$tempdir/lib/$_" or die "copy failed: $!"; -} - -chdir $tempdir; - -my $fp = App::FatPacker->new; -my $temp_fh = File::Temp->new; -select $temp_fh; -$fp->script_command_file; -print "1;\n"; -select STDOUT; -close $temp_fh; - -# Packed, now try using it: -require $temp_fh; - -{ - require t::mod::a; - no warnings 'once'; - ok $t::mod::a::foo eq 'bar'; -} diff --git a/t/pack_fatlib.t b/t/pack_fatlib.t new file mode 100644 index 0000000..3b5287f --- /dev/null +++ b/t/pack_fatlib.t @@ -0,0 +1,10 @@ +#!perl +use strict; +use warnings FATAL => 'all'; +use Test::More qw(no_plan); +use FindBin qw/$Bin/; +use File::Spec; + +require File::Spec->catdir($Bin, "pack_lib.t"); +test_with("fatlib"); + diff --git a/t/pack_lib.t b/t/pack_lib.t new file mode 100644 index 0000000..dde0f91 --- /dev/null +++ b/t/pack_lib.t @@ -0,0 +1,43 @@ +#!perl +use strict; +use warnings FATAL => 'all'; +use Test::More; +use File::Basename; +use File::Copy; +use File::Path; +use File::Temp; + +sub test_with { + use_ok "App::FatPacker", ""; + my $dir = shift; + my $tempdir = File::Temp->newdir; + mkpath([<$tempdir/$dir/t/mod>]); + + for() { + copy $_, "$tempdir/$dir/$_" or die "copy failed: $!"; + } + + chdir $tempdir; + + my $fp = App::FatPacker->new; + my $temp_fh = File::Temp->new; + select $temp_fh; + $fp->script_command_file; + print "1;\n"; + select STDOUT; + close $temp_fh; + + # Packed, now try using it: + require $temp_fh; + + { + require t::mod::a; + no warnings 'once'; + ok $t::mod::a::foo eq 'bar'; + } +} + +unless (caller()) { + plan 'no_plan'; + test_with("lib"); +}