Skip to content

Commit feb5f50

Browse files
committed
Only add commands if scaffold is already loaded.
With the new hooks introduced in wp-cli/wp-cli@7fcee0e , we can now only load the commands if the parent they depend on has already been added. This is needed because of the added flexibility provided by the bootstrap refactoring. See wp-cli/wp-cli#3872
1 parent 1cbb3ad commit feb5f50

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

scaffold-package-command.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
return;
55
}
66

7-
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8-
if ( file_exists( $autoload ) ) {
9-
require_once $autoload;
10-
}
7+
WP_CLI::add_hook( 'after_add_command:scaffold', function () {
8+
9+
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
10+
if ( file_exists( $autoload ) ) {
11+
require_once $autoload;
12+
}
13+
14+
WP_CLI::add_command( 'scaffold package', array( 'WP_CLI\ScaffoldPackageCommand', 'package' ) );
15+
WP_CLI::add_command( 'scaffold package-readme', array( 'WP_CLI\ScaffoldPackageCommand', 'package_readme' ) );
16+
WP_CLI::add_command( 'scaffold package-tests', array( 'WP_CLI\ScaffoldPackageCommand', 'package_tests' ) );
1117

12-
WP_CLI::add_command( 'scaffold package', array( 'WP_CLI\ScaffoldPackageCommand', 'package' ) );
13-
WP_CLI::add_command( 'scaffold package-readme', array( 'WP_CLI\ScaffoldPackageCommand', 'package_readme' ) );
14-
WP_CLI::add_command( 'scaffold package-tests', array( 'WP_CLI\ScaffoldPackageCommand', 'package_tests' ) );
18+
} );

0 commit comments

Comments
 (0)