Skip to content

Commit bce0d4b

Browse files
Merge pull request #87 from wp-cli/27-runcommand
Use `WP_CLI::runcommand()` to launch other WP-CLI command processes
2 parents dc42d5f + d3eacbe commit bce0d4b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

inc/ScaffoldPackageCommand.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ public function package( $args, $assoc_args ) {
103103
WP_CLI::success( "Created package files in {$package_dir}" );
104104
}
105105

106+
$force_flag = $force ? '--force' : '';
106107
if ( ! Utils\get_flag_value( $assoc_args, 'skip-tests' ) ) {
107-
WP_CLI::run_command( array( 'scaffold', 'package-tests', $package_dir ), array( 'force' => $force ) );
108+
WP_CLI::runcommand( "scaffold package-tests {$package_dir} {$force_flag}", array( 'launch' => false ) );
108109
}
109110

110111
if ( ! Utils\get_flag_value( $assoc_args, 'skip-readme' ) ) {
111-
WP_CLI::run_command( array( 'scaffold', 'package-readme', $package_dir ), array( 'force' => $force ) );
112+
WP_CLI::runcommand( "scaffold package-readme {$package_dir} {$force_flag}", array( 'launch' => false ) );
112113
}
113114

114-
WP_CLI::run_command( array( 'package', 'install', $package_dir ) );
115+
WP_CLI::runcommand( "package install {$package_dir}", array( 'launch' => false ) );
115116
}
116117

117118
/**
@@ -238,10 +239,7 @@ public function package_readme( $args, $assoc_args ) {
238239

239240
if ( ! empty( $composer_obj['extra']['commands'] ) ) {
240241
$readme_args['commands'] = array();
241-
ob_start();
242-
WP_CLI::run_command( array( 'cli', 'cmd-dump' ) );
243-
$ret = ob_get_clean();
244-
$cmd_dump = json_decode( $ret, true );
242+
$cmd_dump = WP_CLI::runcommand( 'cli cmd-dump', array( 'launch' => false, 'return' => true, 'parse' => 'json' ) );
245243
foreach( $composer_obj['extra']['commands'] as $command ) {
246244
$bits = explode( ' ', $command );
247245
$parent_command = $cmd_dump;

0 commit comments

Comments
 (0)