Skip to content

Commit bb2560c

Browse files
committed
only load MooseX::Getopt in script role
MooseX::Getopt is used in our scripts, and we need to tell it about some of the types we use. But that is only needed in the scripts. Rather than setting it up in the type module, we can set it up in the role that is used in every script. This means it won't be loaded in the web app.
1 parent 0b2f286 commit bb2560c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/MetaCPAN/Role/Script.pm

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use MetaCPAN::Util qw( root_dir );
1212
use Mojo::Server ();
1313
use Term::ANSIColor qw( colored );
1414

15+
use MooseX::Getopt::OptionTypeMap ();
16+
for my $type ( Path, AbsPath ) {
17+
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $type, '=s' );
18+
}
19+
1520
with( 'MetaCPAN::Role::HasConfig', 'MetaCPAN::Role::Fastly',
1621
'MetaCPAN::Role::Logger' );
1722

lib/MetaCPAN/Types/TypeTiny.pm

-7
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ coerce HashRefCPANMeta, from InstanceOf ['CPAN::Meta'], via {
121121
return $struct ? $struct : $_->as_struct;
122122
};
123123

124-
# optionally add Getopt option type (adapted from MooseX::Types:Path::Class)
125-
if ( eval { require MooseX::Getopt; 1 } ) {
126-
for my $type ( Path, AbsPath ) {
127-
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $type, '=s' );
128-
}
129-
}
130-
131124
declare CommaSepOption, as ArrayRef [ StrMatch [qr{^[^, ]+$}] ];
132125
coerce CommaSepOption, from ArrayRef [Str], via {
133126
return [ map split(/\s*,\s*/), @$_ ];

0 commit comments

Comments
 (0)