Navigation Menu

Skip to content

Commit

Permalink
scripts should be a little more portable (closes #896)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 12, 2016
1 parent 966f804 commit f662f96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,5 @@

6.40 2016-01-11
6.40 2016-01-12
- Removed client_challenge, client_handshake and server_handshake methods from
Mojo::Transaction::WebSocket. (batman)
- Removed is_writing method from Mojo::Transaction.
Expand All @@ -16,6 +16,7 @@
- Improved performance of Mojo::Server::Daemon and Mojo::UserAgent slightly.
- Improved mtime attribute in Mojo::Asset::Memory to default to the value of
$^T.
- Improved app generator command to generate more portable scripts.
- Fixed a few timing bugs.
- Fixed url_for to handle fragments correctly.

Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/generate/app.pm
Expand Up @@ -117,7 +117,8 @@ __DATA__
use strict;
use warnings;
use lib 'lib';
use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
# Start command line interface for application
require Mojolicious::Commands;
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -1447,11 +1447,9 @@ automatically installed with the modules.

1;

Finally a few small changes should be made to the application script. The
shebang becomes the recommended C<#!perl>, which the toolchain rewrites to the
proper shebang during installation. Also use L<FindBin> rather than L<lib>,
since installable scripts can't use L<lib> without breaking updated dual-life
modules.
Finally there is just one small change to be made to the application script. The
shebang line becomes the recommended C<#!perl>, which the toolchain can rewrite
to the proper shebang during installation.

#!perl

Expand Down
15 changes: 15 additions & 0 deletions lib/Mojolicious/Guides/Growing.pod
Expand Up @@ -744,6 +744,21 @@ C<my_app> to follow the CPAN standard.
$ mkdir script
$ mv myapp.pl script/my_app

Just a few small details change, instead of L<lib> we now use L<FindBin> and
C<@ISA>, allowing us to start the application from outside its home directory.

#!/usr/bin/env perl

use strict;
use warnings;

use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }

# Start command line interface for application
require Mojolicious::Commands;
Mojolicious::Commands->start_app('MyApp');

=head2 Simplified tests

Full L<Mojolicious> applications are a little easier to test, so C<t/login.t>
Expand Down

0 comments on commit f662f96

Please sign in to comment.