Skip to content

Commit

Permalink
Update config:hosts and config:current task recipes (#1901)
Browse files Browse the repository at this point in the history
* Update config:hosts and config:current task recipes

* Update changelog

* Fix variable refs
  • Loading branch information
friartuck6000 authored and antonmedv committed Aug 9, 2019
1 parent 05f6f89 commit 6180366
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Fixed
- fixed invalid magic-property phpdoc in Deployer\Deployer class [#1899]
- Updated `config:hosts` and `config:current` tasks to output only the selected stage


## v6.4.6
Expand Down
10 changes: 7 additions & 3 deletions recipe/config/current.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
desc('Show current paths');
task('config:current', function () {
$rows = [];
$hosts = Deployer::get()->hosts;
$selectedStage = Deployer::get()->getInput()->getArgument('stage');

on(Deployer::get()->hosts, function (Host $host) use (&$rows, $selectedStage) {
if ($host->get('stage') !== $selectedStage) {
return;
}

on($hosts, function (Host $host) use (&$rows) {
try {
$rows[] = [
$host->getHostname(),
basename($host->getConfig()->get('current_path')),
basename($host->get('current_path')),
];
} catch (\Throwable $e) {
$rows[] = [
Expand Down
11 changes: 8 additions & 3 deletions recipe/config/hosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@

desc('Print all hosts');
task('config:hosts', function () {
$hosts = [];
$rows = [];
$selectedStage = Deployer::get()->getInput()->getArgument('stage');

foreach (Deployer::get()->hosts as $host) {
$hosts[] = [
if ($host->get('stage') !== $selectedStage) {
continue;
}

$rows[] = [
$host->getHostname(),
$host->getRealHostname(),
$host->get('stage', ''),
Expand All @@ -26,6 +31,6 @@
$table = new Table(output());
$table
->setHeaders(['Host', 'Hostname', 'Stage', 'Roles', 'Deploy path'])
->setRows($hosts);
->setRows($rows);
$table->render();
})->once();

0 comments on commit 6180366

Please sign in to comment.