From be8316a5a026642103b5e978ca549409d42d525b Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 24 Jun 2016 16:55:50 +0900 Subject: find_bins fallback --- lib/DhMakeELPA/Command/Packaging.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/DhMakeELPA/Command/Packaging.pm b/lib/DhMakeELPA/Command/Packaging.pm index 00eef51..b01d6cb 100644 --- a/lib/DhMakeELPA/Command/Packaging.pm +++ b/lib/DhMakeELPA/Command/Packaging.pm @@ -71,9 +71,15 @@ sub find_bins { my @el_files = glob($self->main_dir . "/*.el"); my @pkg_files = glob($self->main_dir . "/*-pkg.el"); @el_files = array_minus( @el_files, @pkg_files ); - if (@el_files == 1) { + # try to ensure that the 'root' .el file is at the front of the list + @el_files = sort { length $a cmp length $b } @el_files; + my $single_bin = sub { my $bin = basename($el_files[0]) =~ s/\.el$//r; $self->bins({ "$bin" => ("*.el") }); + }; + + if (@el_files == 1) { + &$single_bin(); } else { $self->bins({}); # there could be -pkg.el files that don't have an associated .el @@ -90,6 +96,11 @@ sub find_bins { $self->bins->{$name} = \@files; } } + # fallback: if we failed to figure out the bins, just use a + # single one + if ( scalar %{$self->bins} eq 0) { + &$single_bin(); + } } } -- cgit v1.2.3