Skip to content

Commit 7d65b76

Browse files
authored
Merge pull request #15 from wp-cli/13-extract-router
Properly extract router.php from the Phar build
2 parents a78a777 + 5ea07a8 commit 7d65b76

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Server_Command.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,21 @@ function __invoke( $_, $assoc_args ) {
7575
}
7676
}
7777

78+
// Get the path to the router file
79+
$router_path = WP_CLI_ROOT . '/vendor/wp-cli/server-command/router.php';
80+
if ( ! file_exists( $router_path ) ) {
81+
// server command must've been built with vendor/wp-cli/wp-cli
82+
$router_path = WP_CLI_ROOT . '/../../../router.php';
83+
if ( ! file_exists( $router_path ) ) {
84+
WP_CLI::error( "Couldn't find router.php" );
85+
}
86+
}
7887
$cmd = \WP_CLI\Utils\esc_cmd( '%s -S %s -t %s -c %s %s',
7988
WP_CLI::get_php_binary(),
8089
$assoc_args['host'] . ':' . $assoc_args['port'],
8190
$docroot,
8291
$assoc_args['config'],
83-
dirname( dirname( __FILE__ ) ) . '/router.php'
92+
\WP_CLI\Utils\extract_from_phar( $router_path )
8493
);
8594

8695
$descriptors = array( STDIN, STDOUT, STDERR );

0 commit comments

Comments
 (0)