Skip to content

Commit

Permalink
Run system check on before_invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Mar 13, 2017
1 parent c6849d9 commit f3f5993
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 8 additions & 1 deletion server-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@
require_once $autoload;
}

WP_CLI::add_command( 'server', 'Server_Command', array() );
WP_CLI::add_command( 'server', 'Server_Command', array(
'before_invoke' => function() {
$min_version = '5.4';
if ( version_compare( PHP_VERSION, $min_version, '<' ) ) {
WP_CLI::error( "The `wp server` command requires PHP {$min_version} or newer." );
}
}
) );
5 changes: 0 additions & 5 deletions src/Server_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class Server_Command extends WP_CLI_Command {
* @when before_wp_load
*/
function __invoke( $_, $assoc_args ) {
$min_version = '5.4';
if ( version_compare( PHP_VERSION, $min_version, '<' ) ) {
WP_CLI::error( "The `wp server` command requires PHP $min_version or newer." );
}

$defaults = array(
'host' => 'localhost',
'port' => 8080,
Expand Down

0 comments on commit f3f5993

Please sign in to comment.