Change selecting servers behavior. 💎

This commit is contained in:
Anton Medvedev 2015-05-13 17:07:15 +07:00
parent b5b8e7278c
commit e0b418e85f
2 changed files with 21 additions and 6 deletions

View File

@ -89,12 +89,16 @@ class TaskCommand extends Command
}
} else {
// Otherwise run on all servers.
$servers = iterator_to_array($this->deployer->servers->getIterator());
// Otherwise run on all servers what does not specify stage.
foreach($this->deployer->environments as $name => $env) {
if (!$env->has('stages')) {
$servers[$name] = $this->deployer->servers->get($name);
}
}
}
if (empty($servers)) {
throw new \RuntimeException('You need specify at least one server.');
throw new \RuntimeException('You need specify at least one server or stage.');
}
$environments = iterator_to_array($this->deployer->environments);

View File

@ -36,7 +36,7 @@ class Environment
/**
* @param string $name
* @param int|string|array $value
* @param bool|int|string|array $value
*/
public function set($name, $value)
{
@ -45,8 +45,8 @@ class Environment
/**
* @param string $name
* @param int|string|array $default
* @return int|string|array
* @param bool|int|string|array $default
* @return bool|int|string|array
* @throws \RuntimeException
*/
public function get($name, $default = null)
@ -72,6 +72,17 @@ class Environment
return $this->parse($value);
}
/**
* Checks if env var exists.
*
* @param string $name
* @return bool
*/
public function has($name)
{
return $this->values->hasKey($name);
}
/**
* @return mixed
*/