| 1 | package Dist::Inkt::Role::MetaProvidesScripts; | ||
| 2 | |||
| 3 | our $AUTHORITY = 'cpan:TOBYINK'; | ||
| 4 | our $VERSION = '0.026'; | ||
| 5 | |||
| 6 | use Moose::Role; | ||
| 7 | use Path::Tiny 'path'; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | after PopulateMetadata => sub | ||
| 11 | { | ||
| 12 | my $self = shift; | ||
| 13 | $self->log("Finding provided scripts"); | ||
| 14 | |||
| 15 | my $src = $self->sourcefile; | ||
| 16 | |||
| 17 | ### XXX - should filter by manifest_skip | ||
| 18 | my %scripts = ( | ||
| 19 | map { | ||
| 20 | my $path = path($_); | ||
| 21 | $path->basename => { file => $path->relative($src) }; | ||
| 22 | } | ||
| 23 | map { | ||
| 24 | $_->children; | ||
| 25 | } | ||
| 26 | grep { | ||
| 27 | $_->exists; | ||
| 28 | } | ||
| 29 | ( | ||
| 30 | $src->child('bin'), | ||
| 31 | $src->child('script'), | ||
| 32 | ), | ||
| 33 | ); | ||
| 34 | |||
| 35 | $self->metadata->{x_provides_scripts} = \%scripts if scalar keys %scripts; | ||
| 36 | }; | ||
| 37 | |||
| 38 | 1; |