File Coverage

blib/lib/Dist/Zilla/App/Command/run.pm
Criterion Covered Total %
statement 6 18 33.3
branch 0 6 0.0
condition n/a
subroutine 2 7 28.5
pod 5 5 100.0
total 13 36 36.1


line stmt bran cond sub pod time code
1             # ABSTRACT: run stuff in a dir where your dist is built
2              
3             use Dist::Zilla::Pragmas;
4 4     4   2799  
  4         10  
  4         23  
5             use Dist::Zilla::App -command;
6 4     4   28  
  4         8  
  4         29  
7             #pod =head1 SYNOPSIS
8             #pod
9             #pod $ dzil run ./bin/myscript
10             #pod $ dzil run prove -bv t/mytest.t
11             #pod $ dzil run bash
12             #pod
13             #pod =head1 DESCRIPTION
14             #pod
15             #pod This command will build your dist with Dist::Zilla, then build the
16             #pod distribution and then run a command in the build directory. It's something
17             #pod like doing this:
18             #pod
19             #pod dzil build
20             #pod rsync -avp My-Project-version/ .build/
21             #pod cd .build
22             #pod perl Makefile.PL # or perl Build.PL
23             #pod make # or ./Build
24             #pod export PERL5LIB=$PWD/blib/lib:$PWD/blib/arch
25             #pod <your command as defined by rest of params>
26             #pod
27             #pod Except for the fact it's built directly in a subdir of .build (like
28             #pod F<.build/69105y2>).
29             #pod
30             #pod A command returning with an non-zero error code will left the build directory
31             #pod behind for analysis, and C<dzil> will exit with a non-zero status. Otherwise,
32             #pod the build directory will be removed and dzil will exit with status zero.
33             #pod
34             #pod If no run command is provided, a new default shell is invoked. This can be
35             #pod useful for testing your distribution as if it were installed.
36             #pod
37             #pod =cut
38              
39              
40 0     0 1   [ 'build!' => 'do the Build actions before running the command; done by default',
41             { default => 1 } ],
42             [ 'trial' => 'build a trial release that PAUSE will not index' ],
43 0     0 1   }
44              
45             "This will build your dist and run the given 'command' in the build dir.\n" .
46             "If no command was specified, your shell will be run there instead."
47             }
48              
49 0     0 1   return '%c run %o [ command [ arg1 arg2 ... ] ]';
50             }
51              
52             my ($self, $opt, $args) = @_;
53              
54 0     0 1   unless (@$args) {
55             my $envname = $^O eq 'MSWin32' ? 'COMSPEC' : 'SHELL';
56             unless ($ENV{$envname}) {
57             $self->usage_error("no command supplied to run and no \$$envname set");
58 0     0 1   }
59             $args = [ $ENV{$envname} ];
60 0 0         $self->log("no command supplied to run so using \$$envname: $args->[0]");
61 0 0         }
62 0 0          
63 0           $self->zilla->run_in_build($args, { build => $opt->build, trial => $opt->trial });
64             }
65 0            
66 0           1;
67              
68              
69 0           =pod
70              
71             =encoding UTF-8
72              
73             =head1 NAME
74              
75             Dist::Zilla::App::Command::run - run stuff in a dir where your dist is built
76              
77             =head1 VERSION
78              
79             version 6.028
80              
81             =head1 SYNOPSIS
82              
83             $ dzil run ./bin/myscript
84             $ dzil run prove -bv t/mytest.t
85             $ dzil run bash
86              
87             =head1 DESCRIPTION
88              
89             This command will build your dist with Dist::Zilla, then build the
90             distribution and then run a command in the build directory. It's something
91             like doing this:
92              
93             dzil build
94             rsync -avp My-Project-version/ .build/
95             cd .build
96             perl Makefile.PL # or perl Build.PL
97             make # or ./Build
98             export PERL5LIB=$PWD/blib/lib:$PWD/blib/arch
99             <your command as defined by rest of params>
100              
101             Except for the fact it's built directly in a subdir of .build (like
102             F<.build/69105y2>).
103              
104             A command returning with an non-zero error code will left the build directory
105             behind for analysis, and C<dzil> will exit with a non-zero status. Otherwise,
106             the build directory will be removed and dzil will exit with status zero.
107              
108             If no run command is provided, a new default shell is invoked. This can be
109             useful for testing your distribution as if it were installed.
110              
111             =head1 PERL VERSION
112              
113             This module should work on any version of perl still receiving updates from
114             the Perl 5 Porters. This means it should work on any version of perl released
115             in the last two to three years. (That is, if the most recently released
116             version is v5.40, then this module should work on both v5.40 and v5.38.)
117              
118             Although it may work on older versions of perl, no guarantee is made that the
119             minimum required version will not be increased. The version may be increased
120             for any reason, and there is no promise that patches will be accepted to lower
121             the minimum required perl.
122              
123             =head1 AUTHOR
124              
125             Ricardo SIGNES 😏 <cpan@semiotic.systems>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is copyright (c) 2022 by Ricardo SIGNES.
130              
131             This is free software; you can redistribute it and/or modify it under
132             the same terms as the Perl 5 programming language system itself.
133              
134             =cut