Atomic symlink.

This commit is contained in:
Anton Medvedev 2016-11-05 15:42:44 +07:00
parent 4724625840
commit 86de97a5ab

View File

@ -85,8 +85,7 @@ env('bin/composer', function () {
*/
env('bin/symlink', function () {
if (env('use_relative_symlink')) {
$man = run('man ln')->toString();
if (strpos($man, '--relative') !== false) {
if (run('if [[ "$(man ln)" =~ "--relative" ]]; then echo "true"; fi')->toBool()) {
return 'ln -nfs --relative';
}
}
@ -419,8 +418,15 @@ task('deploy:vendors', function () {
* Create symlink to last release.
*/
task('deploy:symlink', function () {
run("cd {{deploy_path}} && {{bin/symlink}} {{release_path}} current"); // Atomic override symlink.
run("cd {{deploy_path}} && rm release"); // Remove release link.
if (run('if [[ "$(man mv)" =~ "--no-target-directory" ]]; then echo "true"; fi')->toBool()) {
run("mv -T {{deploy_path}}/release {{deploy_path}}/current");
} else {
// Atomic symlink does not supported.
// Will use simple≤ two steps switch.
run("cd {{deploy_path}} && {{bin/symlink}} {{release_path}} current"); // Atomic override symlink.
run("cd {{deploy_path}} && rm release"); // Remove release link.
}
})->desc('Creating symlink to release');