Skip to content

Commit

Permalink
add [MetaJSON] to [@basic]
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Jul 3, 2017
1 parent f212d77 commit 62ef27a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- [MetaJSON] is now in [@Basic], with special handling to handle the
possibility the plugin is loaded twice

6.009 2017-03-04 11:16:37-05:00 America/New_York
- update DateTime::TimeZone prereq on Win32 to improve workingness
Expand Down
7 changes: 7 additions & 0 deletions lib/Dist/Zilla/Plugin/MetaJSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use Moose;
with 'Dist::Zilla::Role::FileGatherer';
use Moose::Util::TypeConstraints;

use List::Util 'first';
use namespace::autoclean;

=head1 DESCRIPTION
Expand Down Expand Up @@ -54,6 +55,12 @@ sub gather_files {

my $zilla = $self->zilla;

# gracefully handle there being more than one of us (e.g. one via [@Basic])
if ((first { $_->isa(__PACKAGE__) } @{ $self->zilla->plugins }) != $self) {
$self->log('doing nothing: another [MetaJSON] already ran...');
return;
}

require JSON::MaybeXS;
require Dist::Zilla::File::FromCode;
require CPAN::Meta::Converter;
Expand Down
2 changes: 2 additions & 0 deletions lib/Dist/Zilla/PluginBundle/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sub configure {
PruneCruft
ManifestSkip
MetaYAML
MetaJSON
License
Readme
ExtraTests
Expand Down Expand Up @@ -45,6 +46,7 @@ It includes the following plugins with their default configuration:
* L<Dist::Zilla::Plugin::PruneCruft>
* L<Dist::Zilla::Plugin::ManifestSkip>
* L<Dist::Zilla::Plugin::MetaYAML>
* L<Dist::Zilla::Plugin::MetaJSON>
* L<Dist::Zilla::Plugin::License>
* L<Dist::Zilla::Plugin::Readme>
* L<Dist::Zilla::Plugin::ExtraTests>
Expand Down
37 changes: 37 additions & 0 deletions t/plugins/metajson.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use strict;
use warnings;

use Test::More 0.88;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Test::DZil;
use Test::Fatal;
use Path::Tiny;

{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
'source/dist.ini' => simple_ini(
'@Basic',
'MetaJSON',
),
},
},
);

$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);

my $build_dir = path($tzil->tempdir)->child('build');
ok(-e $build_dir->child('META.json'), 'META.json was created successfully');

diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}

done_testing;

0 comments on commit 62ef27a

Please sign in to comment.