Skip to content

Commit

Permalink
Regenerate cpanfile on make
Browse files Browse the repository at this point in the history
  • Loading branch information
cxw42 committed May 9, 2020
1 parent 5c8f532 commit 8a52b9d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sub get_perl_filename {
# installed.

my $make_readme_md = File::Spec->catfile(qw(support readme.pl));
my $make_cpanfile = File::Spec->catfile(qw(support cpanfile.pl));
return <<EOT;
authortest:
\tRELEASE_TESTING=1 prove -lvj4 xt
Expand All @@ -111,8 +112,11 @@ README.md: @{[$VERSION_FROM]} Makefile.PL $make_readme_md
README: @{[$VERSION_FROM]} Makefile.PL $make_readme_md
\t"$secure_perl_path" "$make_readme_md" -i "\$<" -o "\$@" -f text --appveyor hopenbuild/Data-Hopen --travis hopenbuild/Data-Hopen
all :: README.md README
dist :: README.md README
cpanfile: @{[$VERSION_FROM]} Makefile.PL $make_cpanfile MYMETA.json
\t"$secure_perl_path" "$make_cpanfile"
all :: README.md README cpanfile
dist :: README.md README cpanfile
# Uninstallation: mimic what the normal "uninstall" target does, but actually
# carry out the actions.
Expand Down
21 changes: 21 additions & 0 deletions support/cpanfile.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env perl
package # hide from PAUSE
makecpanfile;

# Make a cpanfile from the dependencies in Makefile.PL.
# Modified from https://github.com/miyagawa/cpanfile/blob/master/README.md
# by miyagawa. Assumes MYMETA.json has already been created.
use strict;
use warnings;

use CPAN::Meta;
use File::Slurp qw(write_file);
use Module::CPANfile;

my $meta = CPAN::Meta->load_file("MYMETA.json");
my $file = Module::CPANfile->from_prereqs($meta->prereqs);
my $contents = <<EOT . $file->to_string;
# Auto-generated from Makefile.PL by cpanfile-from-Makefile-PL
EOT
# Note: No timestamp so that the header line doesn't show up in the git diff
write_file('cpanfile', $contents);

0 comments on commit 8a52b9d

Please sign in to comment.