Skip to content

Commit f7b690f

Browse files
committed
Replace curl cli with http_request
1 parent 988caa3 commit f7b690f

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/Context/FeatureContext.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,11 @@ private static function download_sqlite_plugin( $dir ): void {
574574
mkdir( $dir );
575575
}
576576

577-
$curl = self::is_windows() ? 'curl.exe' : 'curl';
577+
$response = Utils\http_request( 'GET', $download_url, null, [], [ 'filename' => $download_location ] );
578578

579-
Process::create(
580-
Utils\esc_cmd(
581-
"$curl -sSfL %1\$s > %2\$s",
582-
$download_url,
583-
$download_location
584-
)
585-
)->run_check();
579+
if ( 200 !== $response->status_code ) {
580+
throw new RuntimeException( "Could not download SQLite plugin (HTTP code {$response->status_code})" );
581+
}
586582

587583
$zip = new \ZipArchive();
588584
$new_zip_file = $download_location;
@@ -1096,15 +1092,11 @@ public function download_phar( $version = 'same' ): void {
10961092
. uniqid( 'wp-cli-download-', true )
10971093
. '.phar';
10981094

1099-
$curl = self::is_windows() ? 'curl.exe' : 'curl';
1095+
$response = Utils\http_request( 'GET', $download_url, null, [], [ 'filename' => $this->variables['PHAR_PATH'] ] );
11001096

1101-
Process::create(
1102-
Utils\esc_cmd(
1103-
"$curl -sSfL %1\$s > %2\$s && chmod +x %2\$s",
1104-
$download_url,
1105-
$this->variables['PHAR_PATH']
1106-
)
1107-
)->run_check();
1097+
if ( 200 !== $response->status_code ) {
1098+
throw new RuntimeException( "Could not download WP-CLI PHAR (HTTP code {$response->status_code})" );
1099+
}
11081100
}
11091101

11101102
/**

0 commit comments

Comments
 (0)