App-GhaInstall
view release on metacpan or search on metacpan
lib/App/GhaInstall.pm view on Meta::CPAN
use 5.006;
use strict;
use warnings;
package App::GhaInstall;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.004';
our $ALLOW_FAIL = 0;
our $DRY_RUN = 0;
sub SHOULD_INSTALL_OPTIONAL_DEPS () {
no warnings;
$ENV{GHA_TESTING_COVER} =~ /^(true|1)$/i
or $ENV{GHA_INSTALL_OPTIONAL} =~ /^(true|1)$/i
}
sub SHOULD_INSTALL_COVERAGE_DEPS () {
no warnings;
$ENV{GHA_TESTING_COVER} =~ /^(true|1)$/i
}
sub SHOULD_INSTALL_GITHUB_DEPS () {
no warnings;
!! $ENV{CI}
}
my $installer;
sub INSTALLER () {
return $installer if defined $installer;
if ( $ENV{GHA_INSTALL_BACKEND} ) {
$installer = $ENV{GHA_INSTALL_BACKEND};
}
elsif ( $] lt '5.008001' ) {
$installer = 'cpan';
}
else {
my $output = `cpanm --version`;
if ( $output =~ /cpanminus/ ) {
$installer = 'cpanm';
}
else {
$output = `cpm --help`;
if ( $output =~ /install/ ) {
$installer = 'cpm';
}
else {
$installer = 'cpan';
}
}
}
ensure_configured_cpan() if $installer eq 'cpan';
return $installer;
}
sub go {
shift;
my @modules;
foreach ( @_ ) {
if ( /--allow-fail/ ) {
$ALLOW_FAIL = 1;
}
elsif ( /--dry-run/ ) {
$DRY_RUN = 1;
}
elsif ( /--bootstrap/ ) {
install_module( __PACKAGE__ );
local $ALLOW_FAIL = 1;
install_module( 'CPAN' ) if INSTALLER eq 'cpan';
}
elsif ( /--configure/ ) {
install_configure_dependencies();
}
elsif ( /--auto/ ) {
install_dependencies();
}
else {
push @modules, $_;
}
}
if ( @modules ) {
install_modules( @modules );
}
return 0;
}
sub slurp {
my $file = shift;
open my $fh, '<', $file
or die "$file exists but cannot be read\n";
( run in 1.319 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )