@@ -324,9 +324,9 @@ public static function get_vendor_dir(): ?string {
324324 // We try to detect the vendor folder in the most probable locations.
325325 $ vendor_locations = [
326326 // wp-cli/wp-cli-tests is a dependency of the current working dir.
327- getcwd () . ' / vendor ' ,
327+ getcwd () . DIRECTORY_SEPARATOR . ' vendor ' ,
328328 // wp-cli/wp-cli-tests is the root project.
329- dirname ( __DIR__ , 2 ) . ' / vendor ' ,
329+ dirname ( __DIR__ , 2 ) . DIRECTORY_SEPARATOR . ' vendor ' ,
330330 // wp-cli/wp-cli-tests is a dependency.
331331 dirname ( __DIR__ , 4 ),
332332 ];
@@ -365,7 +365,7 @@ public static function get_framework_dir(): ?string {
365365 // wp-cli/wp-cli is the root project.
366366 dirname ( $ vendor_folder ),
367367 // wp-cli/wp-cli is a dependency.
368- "{ $ vendor_folder} / wp-cli/ wp-cli" ,
368+ $ vendor_folder . DIRECTORY_SEPARATOR . ' wp-cli ' . DIRECTORY_SEPARATOR . ' wp-cli ' ,
369369 ];
370370
371371 $ framework_folder = '' ;
@@ -402,32 +402,17 @@ public static function get_bin_path(): ?string {
402402 }
403403
404404 $ bin_paths = [
405- self ::get_vendor_dir () . ' / bin ' ,
406- self ::get_framework_dir () . ' / bin ' ,
405+ self ::get_vendor_dir () . DIRECTORY_SEPARATOR . ' bin ' ,
406+ self ::get_framework_dir () . DIRECTORY_SEPARATOR . ' bin ' ,
407407 ];
408408
409- if ( Utils \is_windows () ) {
410- foreach ( $ bin_paths as $ path ) {
411- $ wp_script_path = $ path . DIRECTORY_SEPARATOR . 'wp ' ;
412- $ wp_bat_path = $ path . DIRECTORY_SEPARATOR . 'wp.bat ' ;
413-
414- if ( is_file ( $ wp_script_path ) ) {
415- if ( ! is_file ( $ wp_bat_path ) ) {
416- $ bat_content = '@ECHO OFF ' . PHP_EOL ;
417- $ bat_content .= 'php " ' . realpath ( $ wp_script_path ) . '" %* ' ;
418- file_put_contents ( $ wp_bat_path , $ bat_content );
419- }
420- $ bin_path = $ path ;
421- break ;
422- }
423- }
424- } else {
425- foreach ( $ bin_paths as $ path ) {
426- $ full_bin_path = $ path . DIRECTORY_SEPARATOR . 'wp ' ;
427- if ( is_file ( $ full_bin_path ) && is_executable ( $ full_bin_path ) ) {
428- $ bin_path = $ path ;
429- break ;
430- }
409+ $ bin = Utils \is_windows () ? 'wp.bat ' : 'wp ' ;
410+
411+ foreach ( $ bin_paths as $ path ) {
412+ $ full_bin_path = $ path . DIRECTORY_SEPARATOR . $ bin ;
413+ if ( is_file ( $ full_bin_path ) && is_executable ( $ full_bin_path ) ) {
414+ $ bin_path = $ path ;
415+ break ;
431416 }
432417 }
433418
@@ -455,14 +440,14 @@ private static function get_process_env_variables(): array {
455440
456441 wp_cli_behat_env_debug ( "WP-CLI binary path: {$ bin_path }" );
457442
458- $ executable = Utils \is_windows () ? $ bin_path . DIRECTORY_SEPARATOR . 'wp.bat ' : $ bin_path . DIRECTORY_SEPARATOR . 'wp ' ;
443+ $ bin = $ bin_path . DIRECTORY_SEPARATOR . ( Utils \is_windows () ? 'wp.bat ' : 'wp ' ) ;
459444
460- if ( ! file_exists ( $ executable ) ) {
461- wp_cli_behat_env_debug ( "WARNING: File $ executable not found. " );
445+ if ( ! file_exists ( $ bin ) ) {
446+ wp_cli_behat_env_debug ( "WARNING: File $ bin not found. " );
462447 }
463448
464- if ( ! is_executable ( $ executable ) ) {
465- wp_cli_behat_env_debug ( "WARNING: File $ executable is not executable. " );
449+ if ( ! is_executable ( $ bin ) ) {
450+ wp_cli_behat_env_debug ( "WARNING: File $ bin is not executable. " );
466451 }
467452
468453 $ path_separator = Utils \is_windows () ? '; ' : ': ' ;
@@ -933,18 +918,19 @@ private function replace_invoke_wp_cli_with_php_args( $str ) {
933918 $ phar_begin = '#!/usr/bin/env php ' ;
934919 $ phar_begin_len = strlen ( $ phar_begin );
935920 $ bin_dir = getenv ( 'WP_CLI_BIN_DIR ' );
921+ $ bin = Utils \is_windows () ? 'wp.bat ' : 'wp ' ;
936922 if ( false !== $ bin_dir && file_exists ( $ bin_dir . '/wp ' ) && file_get_contents ( $ bin_dir . '/wp ' , false , null , 0 , $ phar_begin_len ) === $ phar_begin ) {
937- $ phar_path = $ bin_dir . ' /wp ' ;
923+ $ phar_path = $ bin_dir . $ bin ;
938924 } else {
939925 $ src_dir = dirname ( __DIR__ , 2 );
940- $ bin_path = $ src_dir . '/bin/wp ' ;
941- $ vendor_bin_path = $ src_dir . '/vendor/bin/wp ' ;
926+ $ bin_path = $ src_dir . '/bin/ ' . $ bin ;
927+ $ vendor_bin_path = $ src_dir . '/vendor/bin/ ' . $ bin ;
942928 if ( file_exists ( $ bin_path ) && is_executable ( $ bin_path ) ) {
943929 $ shell_path = $ bin_path ;
944930 } elseif ( file_exists ( $ vendor_bin_path ) && is_executable ( $ vendor_bin_path ) ) {
945931 $ shell_path = $ vendor_bin_path ;
946932 } else {
947- $ shell_path = ' wp ' ;
933+ $ shell_path = $ bin ;
948934 }
949935 }
950936 }
0 commit comments