Skip to content

Commit 3e1fe8d

Browse files
committed
Prepend 'php ' on Windows if the command starts with the phar path.
and other fixes
1 parent b7a36f7 commit 3e1fe8d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Context/FeatureContext.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ public function create_run_dir(): void {
12201220
* @param string $version
12211221
*/
12221222
public function build_phar( $version = 'same' ): void {
1223-
$this->variables['PHAR_PATH'] = $this->variables['RUN_DIR'] . '/' . uniqid( 'wp-cli-build-', true ) . '.phar';
1223+
$this->variables['PHAR_PATH'] = $this->variables['RUN_DIR'] . DIRECTORY_SEPARATOR . uniqid( 'wp-cli-build-', true ) . '.phar';
12241224

12251225
$is_bundle = false;
12261226

@@ -1276,7 +1276,7 @@ public function download_phar( $version = 'same' ): void {
12761276
$version
12771277
);
12781278

1279-
$this->variables['PHAR_PATH'] = $this->variables['RUN_DIR'] . '/'
1279+
$this->variables['PHAR_PATH'] = $this->variables['RUN_DIR'] . DIRECTORY_SEPARATOR
12801280
. uniqid( 'wp-cli-download-', true )
12811281
. '.phar';
12821282

@@ -1396,6 +1396,11 @@ public function proc( $command, $assoc_args = [], $path = '' ): Process {
13961396
$command .= Utils\assoc_args_to_str( $assoc_args );
13971397
}
13981398

1399+
// Prepend 'php ' on Windows if the command starts with the phar path.
1400+
if ( Utils\is_windows() && isset( $this->variables['PHAR_PATH'] ) && 0 === strpos( $command, $this->variables['PHAR_PATH'] ) ) {
1401+
$command = 'php ' . $command;
1402+
}
1403+
13991404
$env = self::get_process_env_variables();
14001405

14011406
if ( isset( $this->variables['SUITE_CACHE_DIR'] ) ) {
@@ -1860,8 +1865,12 @@ public function composer_add_wp_cli_local_repository(): void {
18601865
self::remove_dir( self::$composer_local_repository . '/.git' );
18611866
self::remove_dir( self::$composer_local_repository . '/vendor' );
18621867
}
1863-
$dest = self::$composer_local_repository . '/';
1864-
$this->composer_command( "config repositories.wp-cli '{\"type\": \"path\", \"url\": \"$dest\", \"options\": {\"symlink\": false, \"versions\": { \"wp-cli/wp-cli\": \"dev-main\"}}}'" );
1868+
if ( Utils\is_windows() ) {
1869+
$json_config = '{\"type\": \"path\", \"url\": \"' . str_replace( '\\', '/', $dest ) . '\", \"options\": {\"symlink\": false, \"versions\": { \"wp-cli/wp-cli\": \"dev-main\"}}}';
1870+
$this->composer_command( "config repositories.wp-cli \"$json_config\"" );
1871+
} else {
1872+
$this->composer_command( "config repositories.wp-cli '{\"type\": \"path\", \"url\": \"$dest\", \"options\": {\"symlink\": false, \"versions\": { \"wp-cli/wp-cli\": \"dev-main\"}}}'" );
1873+
}
18651874
$this->variables['COMPOSER_LOCAL_REPOSITORY'] = self::$composer_local_repository;
18661875
}
18671876

0 commit comments

Comments
 (0)