So I was going to run a reverse dependency test against tobyink's updated version of Type::Tiny as mentioned here with my Test::BrewBuild software for fun and real-world testing (essentially, it runs the unit tests of all distributions that are up-river from the module in question to ensure changes don't break them, against both Unix (perlbrew) and Windows (berrybrew) installed Perl instances over the network).

I found a flaw in my software. To get the module name for the distribution from a fetched Git repo, I do a find for the *.pm files in the lib/ directory, and pull the first one. When many module files are found, it may pick the wrong one (such as the case with this dist).

Current code:

sub revdeps { my $self = shift; my $log = $log->child('revdeps'); $log->_6('running --revdep'); my @modules; find({ wanted => sub { if (-f && $_ =~ /\.pm$/){ $log->_7("located module: $_"); push @modules, $_; } }, no_chdir => 1, }, 'lib/' ); my $mod = $modules[0]; $log->_7("using '$mod' as the project we're working on"); $mod =~ s|lib/||; $mod =~ s|/|-|g; $mod =~ s|\.pm||; $log->_7("working module translated to $mod"); my @revdeps = $self->_get_revdeps($mod); return @revdeps; }

I'm wondering if there's a nice, clean way to get the primary module. I need to support ExtUtils::MakeMaker, Module::Build and Dist::Zilla. The only safe way I can think of is to glean this from the respective directives in the Makefile.PL, Build.PL or the dist.ini files. Does anyone know of perhaps a cpanm command or other trick that can fetch the distribution name given only the directory of the dist as opposed to having to load/read the build file?


In reply to Get the top-level module name from a Git repository/dist directory by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.