Skip to content

Commit 107189e

Browse files
author
test
committed
Proper handling of rsync when executed as a phar
1 parent 5363aa9 commit 107189e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.distignore-defaults

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tests
2525
.babelrc
2626
.distinclude
2727
.distignore
28+
.distignore-defaults
2829
.editorconfig
2930
.eslintignore
3031
.eslintrc

src/Commands/Package.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,16 @@ protected function syncFiles( string $source, string $destination ): int {
202202
}
203203
}
204204

205+
$defaults_filename = null;
206+
205207
if ( $use_ignore_defaults ) {
206208
if ( App::isPhar() ) {
207-
$command[] = '--exclude-from=<(php -r \'include ' . escapeshellarg( __PUP_DIR__ . '/.distignore-defaults' ) . ';\')';
209+
$defaults_contents = file_get_contents( __PUP_DIR__ . '/.distignore-defaults' );
210+
$defaults_filename = $working_dir . '.distignore-defaults-' . uniqid();
211+
if ( $defaults_contents ) {
212+
file_put_contents( $defaults_filename, $defaults_contents );
213+
}
214+
$command[] = '--exclude-from=' . escapeshellarg( $defaults_filename );
208215
} else {
209216
$command[] = '--exclude-from=' . escapeshellarg( __PUP_DIR__ . '/.distignore-defaults' );
210217
}
@@ -223,6 +230,11 @@ protected function syncFiles( string $source, string $destination ): int {
223230
$command = implode( ' ', $command );
224231
$result_code = 0;
225232
system( $command, $result_code );
233+
234+
if ( App::isPhar() && $defaults_filename && file_exists( $defaults_filename ) ) {
235+
unlink( $defaults_filename );
236+
}
237+
226238
return $result_code;
227239
}
228240

0 commit comments

Comments
 (0)