Validate shared_dirs on deploy:shared

This commit is contained in:
Anton Medvedev 2017-01-18 13:27:08 +07:00
parent 49a7f55ed7
commit 73e6c3b441
3 changed files with 25 additions and 0 deletions

View File

@ -5,6 +5,7 @@
### Added
- Added `testLocally` function (analog `test` fn)
- Added `ConfigurationException`
### Changed
- Server config `setPty` renamed to `pty` [#953](https://github.com/deployphp/deployer/pull/953)
@ -12,6 +13,7 @@
- `deploy:unlock` now always successful [#950](https://github.com/deployphp/deployer/pull/950)
- Added option `-L` to `setfacl` [#956](https://github.com/deployphp/deployer/pull/956)
- Run `deploy:unlock` when deploy is fail [#958](https://github.com/deployphp/deployer/pull/958)
- Now throw exception on duplicates in `shared_dirs`
### Fixed
- Fixed native ssh scp option

View File

@ -7,10 +7,21 @@
namespace Deployer;
use Deployer\Exception\ConfigurationException;
desc('Creating symlinks for shared files and dirs');
task('deploy:shared', function () {
$sharedPath = "{{deploy_path}}/shared";
// Validate shared_dir, find duplicates
foreach (get('shared_dirs') as $a) {
foreach (get('shared_dirs') as $b) {
if ($a !== $b && strpos($a, $b) === 0) {
throw new ConfigurationException("Can not share same dirs `$a` and `$b`.");
}
}
}
foreach (get('shared_dirs') as $dir) {
// Check if shared dir does not exists.
if (!test("[ -d $sharedPath/$dir ]")) {

View File

@ -0,0 +1,12 @@
<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer\Exception;
class ConfigurationException extends \RuntimeException
{
}