Skip to content

Commit d1a10fa

Browse files
Copilotschlessera
andauthored
Use WP-CLI temp helpers for zip install paths
Co-authored-by: schlessera <83631+schlessera@users.noreply.github.com>
1 parent 2b52764 commit d1a10fa

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎features/package-install.feature‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,25 @@ Feature: Install WP-CLI packages
10171017
wp-cli/google-sitemap-generator-cli
10181018
"""
10191019
1020+
@github-api
1021+
Scenario: Install a package from a remote zip URL
1022+
Given an empty directory
1023+
1024+
When I run `wp package install https://github.com/wp-cli/google-sitemap-generator-cli/archive/main.zip`
1025+
Then STDOUT should contain:
1026+
"""
1027+
Installing package wp-cli/google-sitemap-generator-cli
1028+
"""
1029+
And STDOUT should contain:
1030+
"""
1031+
Success: Package installed.
1032+
"""
1033+
1034+
When I run `wp package is-installed wp-cli/google-sitemap-generator-cli`
1035+
Then the return code should be 0
1036+
And STDERR should be empty
1037+
And STDOUT should be empty
1038+
10201039
@github-api
10211040
Scenario: Install a package from Git using a shortened mixed-case package identifier but lowercase composer.json name
10221041
Given an empty directory

‎src/Package_Command.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function install( $args, $assoc_args ) {
276276
// Download the remote ZIP file to a temp directory
277277
$temp = false;
278278
if ( false !== strpos( $package_name, '://' ) ) {
279-
$temp = Utils\get_temp_dir() . uniqid( 'wp-cli-package_', true /*more_entropy*/ ) . '.zip';
279+
$temp = Utils\make_temp_file( 'wp-cli-package_', '.zip' );
280280
$options = [
281281
'timeout' => 600,
282282
'filename' => $temp,
@@ -291,7 +291,7 @@ public function install( $args, $assoc_args ) {
291291
}
292292
$package_name = $temp;
293293
}
294-
$dir_package = Utils\get_temp_dir() . uniqid( 'wp-cli-package_', true /*more_entropy*/ );
294+
$dir_package = Utils\make_temp_dir( 'wp-cli-package_' );
295295
try {
296296
// Extract the package to get the package name
297297
Extractor::extract( $package_name, $dir_package );

0 commit comments

Comments
 (0)