CPAN-Maker
view release on metacpan or search on metacpan
lib/CPAN/Maker/Role/FileUtils.pm view on Meta::CPAN
#
my ($destdir) = keys %{$e};
my $file_list = $e->{$destdir};
die "ERROR: directory args for extra-files must be an array!\n"
if !is_array($file_list);
push @file_list,
$self->fetch_file_list(
file_list => $file_list,
destination => $destdir,
project_root => $project_root,
);
}
}
return
if !@file_list;
open my $fh, '>', $extra_files_path
or die "ERROR: could not append to $extra_files_path\n";
foreach my $f (@file_list) {
print {$fh} "$f\n";
}
close $fh
or die "ERROR: could not close $extra_files_path\n";
# NOTE: 'extra' (the extra-files output path) has no corresponding
# CLI::Simple accessor (not in option_specs, no extra_options
# declared) -- there is currently nowhere valid to apply this
# value. The file is still written to $extra_files_path above;
# only the tracking of that path is unapplied here.
return;
}
########################################################################
sub parse_path {
########################################################################
my ( $self, $project_root, $path ) = @_;
if ($path) {
if ( $path->{recurse}
&& $path->{recurse} =~ /(yes|no)/ixsm ) {
$self->set_recurse( $path->{recurse} eq 'yes' ? $TRUE : $FALSE );
}
elsif ( $path->{recurse} ) {
die "ERROR: use only yes or no for 'recurse' option\n";
}
if ( $path->{'pm-module'} ) {
$self->set_module_path( $path->{'pm-module'} );
}
# NOTE: 'exclude-files' has no corresponding CLI::Simple accessor
# (not in option_specs, no extra_options declared) -- there is
# currently nowhere valid to apply this buildspec.yml value. Left
# unapplied rather than guessing at an attribute name that
# doesn't exist.
if ( $path->{'exe-files'} ) {
if ( $self->check_path( $project_root, $path->{'exe-files'}, 'exe-files' ) ) {
$self->set_exec_path( $path->{'exe-files'} );
}
}
if ( $path->{scripts} ) {
if ( $self->check_path( $project_root, $path->{scripts}, 'scripts' ) ) {
$self->set_scripts_path( $path->{scripts} );
}
}
if ( $path->{tests} ) {
if ( $self->check_path( $project_root, $path->{tests}, 'tests' ) ) {
$self->set_tests_path( $path->{tests} );
}
}
}
return;
}
########################################################################
sub check_path {
########################################################################
my ( $self, $project_root, $path, $option_name ) = @_;
die sprintf "ERROR: '%s' must be a scalar representing a path not %s\n", $option_name, reftype($path)
if ref $path;
my $exists = $path =~ /^\//xsm ? -d $path : -d "$project_root/$path";
if ( !$exists ) {
warn "WARNING: ** `$path` does not exist or is inaccessible.\n";
warn "WARNING: ** paths should be absolute or relative to $project_root\n";
warn "WARNING: ** Consider removing entry from your buildspec.yml file if this is expected.\n";
return $FALSE;
}
return $TRUE;
}
########################################################################
sub create_temp_filelist {
########################################################################
my ( $self, $project_root, $filelist ) = @_;
if ( ref $filelist && reftype($filelist) eq 'ARRAY' ) {
my ( $fh, $filename ) = tempfile( 'make-cpan-dist-XXXXX', TMPDIR => $TRUE );
foreach my $file ( @{$filelist} ) {
my $path = $file =~ /^\//xsm ? $file : "$project_root/$file";
die "ERROR: no such file $path\n"
if !-e $path;
print {$fh} "$path\n";
}
( run in 0.946 second using v1.01-cache-2.11-cpan-364913b4093 )