From: Dagfinn Ilmari Mannsåker Date: Mon, 5 Mar 2018 16:28:29 +0000 (+0000) Subject: Give more friendly error message for missing M:I author plugins X-Git-Tag: v1.59_01~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b43ba76c85f8f7726fa797810b35057023f1b423;p=dbsrgits%2FSQL-Translator.git Give more friendly error message for missing M:I author plugins --- diff --git a/Makefile.PL b/Makefile.PL index 8f93be1..aaa0f3b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -55,7 +55,6 @@ resources IRC => 'irc://irc.perl.org/#sql-translator'; Meta->{values}{x_authority} = 'cpan:JROBINSON'; all_from 'lib/SQL/Translator.pm'; -readme_from 'lib/SQL/Translator.pm'; for my $type (qw/requires recommends test_requires/) { no strict qw/refs/; @@ -78,26 +77,22 @@ install_share(); tests_recursive (); - -# temporary(?) until I get around to fix M::I wrt xt/ -# needs Module::Install::AuthorTests -eval { - # this should not be necessary since the autoloader is supposed - # to work, but there were reports of it failing - require Module::Install::AuthorTests; - recursive_author_tests (qw/xt/); - 1; -} || do { - if ($Module::Install::AUTHOR) { - my $err = $@; - - # better error message in case of missing dep - eval { require Module::Install::AuthorTests } - || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n"; - - die $err; - } -}; +if ($Module::Install::AUTHOR) { + my @missing_plugins; + for my $plugin (qw(AuthorTests ReadmeFromPod)) { + unless (eval "require Module::Install::$plugin; 1") { + push @missing_plugins, "Module::Install::$plugin"; + chomp(my $err = $@); + $missing_plugins[-1] .= " ($err)" + unless $err =~ m{^Can't locate Module/Install/$plugin\.pm in \@INC}; + } + } + die "\nYou need to install the following modules to run this Makefile.PL in author mode:\n\n", join("\n", @missing_plugins), "\n\n" + if @missing_plugins; + + recursive_author_tests (qw/xt/); + readme_from('lib/SQL/Translator.pm'); +} auto_install();