2016-11-19 15:13:32 +07:00
|
|
|
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
|
2021-10-18 18:29:14 +02:00
|
|
|
// List of paths to remove from {{release_path}}.
|
|
|
|
set('clear_paths', []);
|
|
|
|
|
|
|
|
// Use sudo for deploy:clear_path task?
|
|
|
|
set('clear_use_sudo', false);
|
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Cleanups files and/or directories');
|
2016-11-19 15:13:32 +07:00
|
|
|
task('deploy:clear_paths', function () {
|
|
|
|
$paths = get('clear_paths');
|
2019-10-26 14:30:22 +03:00
|
|
|
$sudo = get('clear_use_sudo') ? 'sudo' : '';
|
2020-01-30 11:08:11 +02:00
|
|
|
$batch = 100;
|
2016-11-19 15:13:32 +07:00
|
|
|
|
2020-01-30 11:08:11 +02:00
|
|
|
$commands = [];
|
2016-11-19 15:13:32 +07:00
|
|
|
foreach ($paths as $path) {
|
2020-01-30 11:08:11 +02:00
|
|
|
$commands[] = "$sudo rm -rf {{release_path}}/$path";
|
|
|
|
}
|
|
|
|
$chunks = array_chunk($commands, $batch);
|
|
|
|
foreach ($chunks as $chunk) {
|
|
|
|
run(implode('; ', $chunk));
|
2016-11-19 15:13:32 +07:00
|
|
|
}
|
|
|
|
});
|