Skip to content

Commit 3143dcc

Browse files
committed
[bin] automatically execute rover exec when needed
1 parent a62e0ee commit 3143dcc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apicast/bin/apicast

+13-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ use Cwd qw(abs_path);
77

88
my $apicast = $ENV{APICAST_DIR} || abs_path(dirname(abs_path(__FILE__)) . '/..');
99
my $bindir = $apicast . '/bin';
10-
my $lua_path = $ENV{LUA_PATH} || ';';
10+
my $lua_path = $ENV{LUA_PATH};
11+
12+
chomp(my $rover = `which rover`);
13+
if ($rover) { $rover = abs_path($rover) }
14+
15+
if ($rover && !$lua_path) {
16+
exec '/usr/bin/env', $rover, 'exec', $0, @ARGV
17+
} else {
18+
$lua_path ||= ';';
19+
}
1120

1221
chdir $apicast;
1322

1423
$ENV{LUA_PATH} = "$apicast/src/?.lua;${lua_path}";
1524

16-
exec '/usr/bin/env', 'resty',
17-
"$bindir/cli", @ARGV;
25+
my @args = ('resty', "$bindir/cli", @ARGV);
26+
27+
exec '/usr/bin/env', @args;

0 commit comments

Comments
 (0)