Skip to content

Commit

Permalink
Merge pull request #20 from danielbachhuber/deprecate-wp-cli
Browse files Browse the repository at this point in the history
Reintroduce autoload so that `wp package` can load the command
  • Loading branch information
danielbachhuber committed Feb 3, 2016
2 parents e8b9e49 + a941ff0 commit a889c4b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
}
],
"minimum-stability": "dev",
"autoload": {
"files": [ "wp-rest-cli.php" ]
},
"require": {},
"require-dev": {
"behat/behat": "~2.5"
Expand Down
16 changes: 13 additions & 3 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@
if ( file_exists( __DIR__ . '/utils.php' ) ) {
require_once __DIR__ . '/utils.php';
require_once __DIR__ . '/Process.php';
$project_config = dirname( dirname( dirname( __FILE__ ) ) ) . '/wp-cli.yml';
if ( file_exists( $project_config ) && ! getenv( 'WP_CLI_CONFIG_PATH' ) ) {
putenv( 'WP_CLI_CONFIG_PATH=' . $project_config );
$project_composer = dirname( dirname( dirname( __FILE__ ) ) ) . '/composer.json';
if ( file_exists( $project_composer ) ) {
$composer = json_decode( file_get_contents( $project_composer ) );
if ( ! empty( $composer->autoload->files ) ) {
$contents = 'require:' . PHP_EOL;
foreach( $composer->autoload->files as $file ) {
$contents .= ' - ' . dirname( dirname( dirname( __FILE__ ) ) ) . '/' . $file;
}
mkdir( sys_get_temp_dir() . '/wp-cli-package-test/' );
$project_config = sys_get_temp_dir() . '/wp-cli-package-test/config.yml';
file_put_contents( $project_config, $contents );
putenv( 'WP_CLI_CONFIG_PATH=' . $project_config );
}
}
// Inside WP-CLI
} else {
Expand Down
2 changes: 0 additions & 2 deletions wp-cli.yml

This file was deleted.

7 changes: 4 additions & 3 deletions wp-rest-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require_once __DIR__ . '/inc/RestCommand.php';
require_once __DIR__ . '/inc/Runner.php';

\WP_REST_CLI\Runner::load_remote_commands();
WP_CLI::add_hook( 'after_wp_load', '\WP_REST_CLI\Runner::after_wp_load' );

if ( class_exists( 'WP_CLI' ) ) {
\WP_REST_CLI\Runner::load_remote_commands();
WP_CLI::add_hook( 'after_wp_load', '\WP_REST_CLI\Runner::after_wp_load' );
}

0 comments on commit a889c4b

Please sign in to comment.