Skip to content

Commit 4eb8169

Browse files
committed
partial revert, add another test
1 parent f7d8cef commit 4eb8169

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

features/scaffold-package-readme.feature

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Feature: Scaffold a README.md file for an existing package
3232
When I run `wp package path`
3333
Then save STDOUT as {PACKAGE_PATH}
3434

35-
When I run `wp scaffold package wp-cli/default-readme`
35+
When I try `wp scaffold package wp-cli/default-readme`
3636
Then STDOUT should contain:
3737
"""
3838
Success: Created package readme.
@@ -66,7 +66,7 @@ Feature: Scaffold a README.md file for an existing package
6666
When I run `wp package path`
6767
Then save STDOUT as {PACKAGE_PATH}
6868

69-
When I run `wp scaffold package wp-cli/custom-branch`
69+
When I try `wp scaffold package wp-cli/custom-branch`
7070
Then STDOUT should contain:
7171
"""
7272
Success: Created package readme.
@@ -90,7 +90,7 @@ Feature: Scaffold a README.md file for an existing package
9090
Scenario: Scaffold a README.md requiring a nightly build
9191
Given an empty directory
9292

93-
When I run `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='>=0.24.0-alpha'`
93+
When I try `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='>=0.24.0-alpha'`
9494
Then STDOUT should contain:
9595
"""
9696
Success: Created package readme.
@@ -115,7 +115,7 @@ Feature: Scaffold a README.md file for an existing package
115115
Scenario: Scaffold a README.md requiring the latest stable release
116116
Given an empty directory
117117

118-
When I run `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='*'`
118+
When I try `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='*'`
119119
Then STDOUT should contain:
120120
"""
121121
Success: Created package readme.
@@ -313,10 +313,20 @@ Feature: Scaffold a README.md file for an existing package
313313
When I try `wp scaffold package-readme foo`
314314
Then STDERR should be:
315315
"""
316-
Error: Command 'profile' is not registered. Make sure it is loaded before running package-readme.
316+
Error: Missing one or more commands defined in composer.json -> extra -> commands.
317317
"""
318318
And the return code should be 1
319319

320+
Scenario: Does not error when commands are specified and present
321+
Given an empty directory
322+
When I try `wp scaffold package wp-cli/foo --dir=foo`
323+
And I try `composer install -d foo`
324+
And I try `wp scaffold package-readme foo`
325+
Then STDERR should not contain:
326+
"""
327+
Error: Missing one or more commands defined in composer.json -> extra -> commands.
328+
"""
329+
320330
Scenario: README for a bundled command
321331
Given an empty directory
322332
And a foo/composer.json file:

src/ScaffoldPackageCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function package( $args, $assoc_args ) {
139139
}
140140

141141
if ( ! Utils\get_flag_value( $assoc_args, 'skip-readme' ) ) {
142-
WP_CLI::runcommand( "scaffold package-readme {$package_dir} {$force_flag}", array( 'launch' => true ) );
142+
WP_CLI::runcommand( "scaffold package-readme {$package_dir} {$force_flag}", array( 'launch' => false ) );
143143
}
144144

145145
if ( ! Utils\get_flag_value( $assoc_args, 'skip-github' ) ) {
@@ -309,9 +309,10 @@ public function package_readme( $args, $assoc_args ) {
309309
$cmd_dump = WP_CLI::runcommand(
310310
'cli cmd-dump',
311311
[
312-
'launch' => false,
313-
'return' => true,
314-
'parse' => 'json',
312+
'launch' => false,
313+
'return' => true,
314+
'parse' => 'json',
315+
'command_args' => [ "--path=$package_dir" ],
315316
]
316317
);
317318
foreach ( $composer_obj['extra']['commands'] as $command ) {
@@ -333,7 +334,7 @@ public function package_readme( $args, $assoc_args ) {
333334
} while ( $parent_command && $bits );
334335

335336
if ( empty( $parent_command ) ) {
336-
WP_CLI::error( "Command '{$command}' is not registered. Make sure it is loaded before running package-readme." );
337+
WP_CLI::error( 'Missing one or more commands defined in composer.json -> extra -> commands.' );
337338
}
338339

339340
$longdesc = isset( $parent_command['longdesc'] ) ? $parent_command['longdesc'] : '';

0 commit comments

Comments
 (0)