@@ -224,7 +224,6 @@ function get_composer_versions( $current_version ) {
224224 $ finder
225225 ->in ( WP_CLI_VENDOR_DIR . '/wp-cli/mustangostang-spyc ' )
226226 ->in ( WP_CLI_VENDOR_DIR . '/wp-cli/php-cli-tools ' )
227- ->in ( WP_CLI_VENDOR_DIR . '/seld/cli-prompt ' )
228227 ->exclude ( 'console ' )
229228 ->exclude ( 'filesystem ' )
230229 ->exclude ( 'composer/ca-bundle ' )
@@ -235,9 +234,6 @@ function get_composer_versions( $current_version ) {
235234 $ finder
236235 ->in ( WP_CLI_VENDOR_DIR . '/wp-cli ' )
237236 ->in ( WP_CLI_VENDOR_DIR . '/nb/oxymel ' )
238- ->in ( WP_CLI_VENDOR_DIR . '/psr ' )
239- ->in ( WP_CLI_VENDOR_DIR . '/seld ' )
240- ->in ( WP_CLI_VENDOR_DIR . '/justinrainbow/json-schema ' )
241237 ->in ( WP_CLI_VENDOR_DIR . '/gettext ' )
242238 ->in ( WP_CLI_VENDOR_DIR . '/mck89 ' )
243239 ->exclude ( 'demo ' )
@@ -253,10 +249,16 @@ function get_composer_versions( $current_version ) {
253249 ->exclude ( 'composer/composer/src/Composer/Question ' )
254250 ->exclude ( 'composer/composer/src/Composer/Repository/Pear ' )
255251 ->exclude ( 'composer/composer/src/Composer/SelfUpdate ' );
252+ }
256253
257- // required by justinrainbow/json-schema v6+.
258- if ( is_dir ( WP_CLI_VENDOR_DIR . '/marc-mabe/php-enum ' ) ) {
259- $ finder ->in ( WP_CLI_VENDOR_DIR . '/marc-mabe/php-enum ' );
254+ // These only exist when a bundled package pulls them in, e.g. composer/composer
255+ // for older versions of wp-cli/package-command. Finder errors out on missing directories.
256+ $ optional_dirs = 'cli ' === BUILD
257+ ? [ 'seld/cli-prompt ' ]
258+ : [ 'psr ' , 'seld ' , 'justinrainbow/json-schema ' , 'marc-mabe/php-enum ' ];
259+ foreach ( $ optional_dirs as $ optional_dir ) {
260+ if ( is_dir ( WP_CLI_VENDOR_DIR . '/ ' . $ optional_dir ) ) {
261+ $ finder ->in ( WP_CLI_VENDOR_DIR . '/ ' . $ optional_dir );
260262 }
261263}
262264
@@ -304,7 +306,7 @@ function get_composer_versions( $current_version ) {
304306}
305307
306308add_file ( $ phar , WP_CLI_VENDOR_DIR . '/autoload.php ' );
307- if ( 'cli ' !== BUILD ) {
309+ if ( 'cli ' !== BUILD && is_dir ( WP_CLI_VENDOR_DIR . ' /composer/composer ' ) ) {
308310 add_file ( $ phar , WP_CLI_VENDOR_DIR . '/composer/composer/LICENSE ' );
309311 add_file ( $ phar , WP_CLI_VENDOR_DIR . '/composer/composer/res/composer-schema.json ' );
310312}
0 commit comments