App-md2html

 view release on metacpan or  search on metacpan

author/fatpack.pl  view on Meta::CPAN

our %clidest = (
    modroot  => \$modroot,
    input    => [],
    outdir   => \$outdir,
    outfn    => \$outfn,
    locallib => \$locallib,
    verbose  => \$verbose,
    debug    => \$debug
);

GetOptions(
    \%clidest,
    'input|file|infile|infname|script=s{,}',
    => sub {
        $patharg->( shift, dest => \@input );
    },
    'outdir|fatpack-out=s',
    'outfn|outfname|out-filename|fnfmt|fmtfn|fmt-filename|fmt-outputfn=s',
    'modroot|module-root|module-dir=s',
    'locallib=s{,}',
    'verbose+',
    'debug',
    '<>' => sub ($in) { $patharg->( $in, dest => \@input ) }
);

my $cliopt_deref = {
    map {
        my $ref = ref $clidest{$_};
        ( $_ => ( $ref eq 'SCALAR' ? $clidest{$_}->$* : $clidest{$_} ) )
    } ( keys %clidest )
};

sub fatpack {
    $CWD = $modroot;
    run( [qw(carton install)] );

    $ENV{PERL5LIB} = "$locallib:$modroot/lib";

    $outdir->mkdir unless -d $outdir;
    dmsg(@input);
    foreach my $in ( map { $_->is_dir ? ( $_->children ) : $_ } @input ) {

        #fatpack($in->children) if $in->is_dir;
        my $fatline = [];
        my $fatstr  = "";
        my @cmd     = ( qw(fatpack pack), $in );

        binmode STDERR, ":encoding(UTF-8)";
        info( "Running " . join " ", @cmd );

        my $run = run( \@cmd, out => $fatline, autochomp => 1 );

        #dmsg($run);

        $fatstr = join "\n", $run->out->lines_utf8;

        my $fatout = $in->basename;
        $fatout = path("$outdir/$fatout")->spew_utf8($fatstr);

        # S_IXOTH  (00001)  execute/search by others
        $fatout->chmod(
            S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH );

        success("Written to: $fatout");
    }
}

fatpack()



( run in 0.604 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )