| 1 | package Dist::Zilla::Plugin::SetScriptShebang; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $DATE = '2014-08-16'; # DATE | |||||||||
| 4 | 1 | our $VERSION = '0.01'; # VERSION | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | with ( | |||||||||
| 12 | 'Dist::Zilla::Role::FileMunger', | ||||||||||
| 13 | 'Dist::Zilla::Role::FileFinderUser' => { | ||||||||||
| 14 | default_finders => [ ':ExecFiles' ], | ||||||||||
| 15 | }, | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub munge_files { | ||||||||
|
Subroutine
munge_files: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 21 | 0 | my $self = shift; | |||||||||
| 22 | |||||||||||
| 23 | 0 | $self->munge_file($_) for @{ $self->found_files }; | |||||||||
| 24 | 0 | return; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub munge_file { | ||||||||
|
Subroutine
munge_file: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 28 | 0 | my ($self, $file) = @_; | |||||||||
| 29 | |||||||||||
| 30 | # should not be necessary because we've filtered for ExecFiles in finder | ||||||||||
| 31 | #unless ($file->name =~ m!^(bin|scripts?)/!) { | ||||||||||
| 32 | # $self->log_debug('Skipping ' . $file->name . ': not script'); | ||||||||||
| 33 | # return; | ||||||||||
| 34 | #} | ||||||||||
| 35 | |||||||||||
| 36 | 0 | my $content = $file->content; | |||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | unless ($content =~ /\A#!/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | $self->log_debug('Skipping ' . $file->name . ': does not contain shebang'); | |||||||||
| 40 | 0 | return; | |||||||||
| 41 | } | ||||||||||
| 42 | 0 | ▶ | if ($content =~ /\A#!perl$/m) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->log_debug('Skipping ' . $file->name . ': already #!perl'); | |||||||||
| 44 | 0 | return; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | $content =~ s/\A#!.+/#!perl/; | |||||||||
| 48 | 0 | $self->log('Setting shebang in script '. $file->name . ' to #!perl'); | |||||||||
| 49 | |||||||||||
| 50 | 0 | $file->content($content); | |||||||||
| 51 | 0 | return; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 55 | 1 | 1; | |||||||||
| 56 | # ABSTRACT: Set script shebang to #!perl | ||||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||