sub _dzil_shim { # shim for working on Dist::Zilla modules my ($self, $cmd_file) = @_; # return early if possible return if -e 'Build.PL' || -e 'Makefile.PL'; return if ! -e 'dist.ini'; my $log = $log->child('_dzil_shim'); $log->_5("dzil dist... loading the shim"); my $path_sep = $self->is_win ? ';' : ':'; if (! grep {-x "$_/dzil"} split /$path_sep/, $ENV{PATH} ){ $log->fatal( "this appears to be a Dist::Zilla module, but the dzil binary " . "can't be found\n" ); } $self->{is_dzil} = 1; open my $fh, '<', 'dist.ini' or croak $!; my ($dist, $version); while (<$fh>){ if (/${ re_brewbuild('extract_dzil_dist_name') }/){ $dist = $1; } if (/${ re_brewbuild('extract_dzil_dist_version') }/){ $version = $1; } last if $dist && $version; } $log->_7("running dzil commands: 'dzil authordeps --missing | cpanm', " . "'dzil build'" ); `dzil authordeps --missing | cpanm`; `dzil clean`; `dzil build`; my $dir = "$dist-$version"; copy $cmd_file, $dir if defined $cmd_file; chdir $dir; $log->_7("entered $dir directory"); } sub _dzil_unshim { # unshim after doing dzil work my $self = shift; my $log = $log->child('_dzil_unshim'); if (! $self->{is_dzil}){ $log->_7("not a dzil distribution; nothing to do"); return; } $log->_5("removing dzil shim"); $self->{is_dzil} = 0; chdir '..'; $log->_7("changed to '..' dir"); }