Skip to content

Commit

Permalink
simplified application detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 6, 2012
1 parent 94e35d1 commit 68dec2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/Mojo/Server.pm
Expand Up @@ -17,6 +17,7 @@ sub new {
sub build_app {
my ($self, $app) = @_;
local $ENV{MOJO_EXE};
local $ENV{MOJO_APP} = $app;
if (my $e = Mojo::Loader->new->load($app)) { die $e if ref $e }
return $app->new;
}
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojolicious/Commands.pm
Expand Up @@ -117,7 +117,7 @@ sub start {

sub start_app {
my $self = shift;
return Mojo::Server->new->build_app($ENV{MOJO_APP} = shift)->start(@_);
return Mojo::Server->new->build_app(shift)->start(@_);
}

sub _command {
Expand Down Expand Up @@ -323,9 +323,8 @@ disabled with the C<MOJO_NO_DETECT> environment variable.
Mojolicious::Commands->start;
Mojolicious::Commands->start(@ARGV);
Start the command line interface for automatically detected application,
usually the value of the C<MOJO_APP> environment variable or
L<Mojo::HelloWorld>.
Start the command line interface for application from the value of the
C<MOJO_APP> environment variable or L<Mojo::HelloWorld>.
# Always start daemon and ignore @ARGV
Mojolicious::Commands->start('daemon', '-l', 'http://*:8080');
Expand Down
3 changes: 1 addition & 2 deletions lib/Test/Mojo.pm
Expand Up @@ -23,8 +23,7 @@ $ENV{MOJO_LOG_LEVEL} ||= $ENV{HARNESS_IS_VERBOSE} ? 'debug' : 'fatal';
sub new {
my $self = shift->SUPER::new;
return $self unless my $app = shift;
return $self->app(
ref $app ? $app : Mojo::Server->new->build_app($ENV{MOJO_APP} = $app));
return $self->app(ref $app ? $app : Mojo::Server->new->build_app($app));
}

sub app {
Expand Down

0 comments on commit 68dec2f

Please sign in to comment.