Skip to content

Commit c03f843

Browse files
add [MetaJSON] to [@basic]
1 parent 09462bc commit c03f843

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

Changes

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Revision history for {{$dist->name}}
33
{{$NEXT}}
44
- restrict [MetaYAML] to metaspec v1.4, [MetaJSON] to v2.0+, as other
55
version combinations are not well-supported by the toolchain
6+
- [MetaJSON] is now in [@Basic], with special handling to handle the
7+
possibility the plugin is loaded twice
68

79
6.006 2016-07-04 10:56:36-04:00 America/New_York
810
- add some documentation to Dist::Zilla::App::Tester (thanks, Alberto

lib/Dist/Zilla/Plugin/MetaJSON.pm

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Moose;
55
with 'Dist::Zilla::Role::FileGatherer';
66
use Moose::Util::TypeConstraints;
77

8+
use List::Util 'first';
89
use namespace::autoclean;
910

1011
=head1 DESCRIPTION
@@ -54,6 +55,12 @@ sub gather_files {
5455

5556
my $zilla = $self->zilla;
5657

58+
# gracefully handle there being more than one of us (e.g. one via [@Basic])
59+
if ((first { $_->isa(__PACKAGE__) } @{ $self->zilla->plugins }) != $self) {
60+
$self->log('doing nothing: another [MetaJSON] already ran...');
61+
return;
62+
}
63+
5764
require JSON::MaybeXS;
5865
require Dist::Zilla::File::FromCode;
5966
require CPAN::Meta::Converter;

lib/Dist/Zilla/PluginBundle/Basic.pm

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sub configure {
1414
PruneCruft
1515
ManifestSkip
1616
MetaYAML
17+
MetaJSON
1718
License
1819
Readme
1920
ExtraTests
@@ -45,6 +46,7 @@ It includes the following plugins with their default configuration:
4546
* L<Dist::Zilla::Plugin::PruneCruft>
4647
* L<Dist::Zilla::Plugin::ManifestSkip>
4748
* L<Dist::Zilla::Plugin::MetaYAML>
49+
* L<Dist::Zilla::Plugin::MetaJSON>
4850
* L<Dist::Zilla::Plugin::License>
4951
* L<Dist::Zilla::Plugin::Readme>
5052
* L<Dist::Zilla::Plugin::ExtraTests>

t/plugins/metajson.t

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use strict;
2+
use warnings;
3+
4+
use Test::More 0.88;
5+
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
6+
use Test::DZil;
7+
use Test::Fatal;
8+
use Path::Tiny;
9+
10+
{
11+
my $tzil = Builder->from_config(
12+
{ dist_root => 'does-not-exist' },
13+
{
14+
add_files => {
15+
'source/dist.ini' => simple_ini(
16+
'@Basic',
17+
'MetaJSON',
18+
),
19+
},
20+
},
21+
);
22+
23+
$tzil->chrome->logger->set_debug(1);
24+
is(
25+
exception { $tzil->build },
26+
undef,
27+
'build proceeds normally',
28+
);
29+
30+
my $build_dir = path($tzil->tempdir)->child('build');
31+
ok(-e $build_dir->child('META.json'), 'META.json was created successfully');
32+
33+
diag 'got log messages: ', explain $tzil->log_messages
34+
if not Test::Builder->new->is_passing;
35+
}
36+
37+
done_testing;

0 commit comments

Comments
 (0)