2016-11-19 15:13:32 +07:00
|
|
|
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
|
2021-10-18 18:29:14 +02:00
|
|
|
// List of dirs to copy between releases.
|
|
|
|
// For example you can copy `node_modules` to speedup npm install.
|
|
|
|
set('copy_dirs', []);
|
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
desc('Copies directories');
|
2016-11-19 15:13:32 +07:00
|
|
|
task('deploy:copy_dirs', function () {
|
2017-04-08 21:20:09 +07:00
|
|
|
if (has('previous_release')) {
|
|
|
|
foreach (get('copy_dirs') as $dir) {
|
2021-09-24 14:07:48 +02:00
|
|
|
// Make sure all path without tailing slash.
|
|
|
|
$dir = trim($dir, '/');
|
|
|
|
|
2017-04-08 21:20:09 +07:00
|
|
|
if (test("[ -d {{previous_release}}/$dir ]")) {
|
2021-09-23 19:03:17 +02:00
|
|
|
$destinationDir = '';
|
|
|
|
if (strpos($dir, '/') !== false) {
|
|
|
|
$destinationDir = substr($dir, 0, strrpos($dir, '/') + 1);
|
|
|
|
}
|
2017-03-09 19:09:28 +01:00
|
|
|
run("mkdir -p {{release_path}}/$dir");
|
2021-09-24 10:45:28 +02:00
|
|
|
// -a, --archive
|
|
|
|
// copy directories recursively, preserve all attributes,
|
|
|
|
// never follow symbolic links in SOURCE
|
|
|
|
// -f, --force
|
|
|
|
// if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n
|
|
|
|
// option is also used)
|
|
|
|
run("cp -af {{previous_release}}/$dir {{release_path}}/$destinationDir");
|
2017-01-27 20:54:21 +07:00
|
|
|
}
|
|
|
|
}
|
2016-11-19 15:13:32 +07:00
|
|
|
}
|
|
|
|
});
|