Skip to content

Commit 6eff23f

Browse files
committed
Merge branch 'master' into 3850-refactor-loading-order
2 parents 83eae34 + f154871 commit 6eff23f

4 files changed

Lines changed: 71 additions & 18 deletions

File tree

‎composer.lock‎

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎features/command.feature‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,3 +753,53 @@ Feature: WP-CLI Commands
753753
"""
754754
Did you mean
755755
"""
756+
757+
Scenario: Adding a command can be aborted through the hooks system
758+
Given an empty directory
759+
And a abort-add-command.php file:
760+
"""
761+
<?php
762+
WP_CLI::add_hook( 'before_add_command:test-command-2', function ( $addition ) {
763+
$addition->abort( 'Testing hooks.' );
764+
} );
765+
766+
WP_CLI::add_command( 'test-command-1', function () {} );
767+
WP_CLI::add_command( 'test-command-2', function () {} );
768+
"""
769+
770+
When I run `wp --require=abort-add-command.php`
771+
Then STDOUT should contain:
772+
"""
773+
test-command-1
774+
"""
775+
And STDOUT should not contain:
776+
"""
777+
test-command-2
778+
"""
779+
780+
Scenario: Adding a command can depend on a previous command having been added before
781+
Given an empty directory
782+
And a add-dependent-command.php file:
783+
"""
784+
<?php
785+
class TestCommand {
786+
}
787+
788+
WP_CLI::add_hook( 'after_add_command:test-command', function () {
789+
WP_CLI::add_command( 'test-command sub-command', function () {} );
790+
} );
791+
792+
WP_CLI::add_command( 'test-command', 'TestCommand' );
793+
"""
794+
795+
When I run `wp --require=add-dependent-command.php`
796+
Then STDOUT should contain:
797+
"""
798+
test-command
799+
"""
800+
801+
When I run `wp --require=add-dependent-command.php help test-command`
802+
Then STDOUT should contain:
803+
"""
804+
sub-command
805+
"""

‎php/boot-phar.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
// Store the path to the Phar early on for `Utils\phar-safe-path()` function.
4+
define( 'WP_CLI_PHAR_PATH', getcwd() );
5+
36
if ( file_exists( 'phar://wp-cli.phar/php/wp-cli.php' ) ) {
47
define( 'WP_CLI_ROOT', 'phar://wp-cli.phar' );
58
include WP_CLI_ROOT . '/php/wp-cli.php';

‎utils/make-phar.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function set_file_contents( $phar, $path, $content ) {
135135
->files()
136136
->ignoreVCS(true)
137137
->ignoreDotFiles(false)
138-
->in( WP_CLI_ROOT . '/vendor/wp-cli/config-command/templates')
138+
->in( WP_CLI_VENDOR_DIR . '/wp-cli/config-command/templates')
139139
;
140140
foreach ( $finder as $file ) {
141141
add_file( $phar, $file );
@@ -146,7 +146,7 @@ function set_file_contents( $phar, $path, $content ) {
146146
->files()
147147
->ignoreVCS(true)
148148
->ignoreDotFiles(false)
149-
->in( WP_CLI_ROOT . '/vendor/wp-cli/scaffold-command/templates')
149+
->in( WP_CLI_VENDOR_DIR . '/wp-cli/scaffold-command/templates')
150150
;
151151
foreach ( $finder as $file ) {
152152
add_file( $phar, $file );

0 commit comments

Comments
 (0)