Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/pretend' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Jun 24, 2013
2 parents 0a04572 + f293ea2 commit f85d699
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,12 +1,15 @@
### Roadmap

- Allow the adding of custom tasks to the CLI (like `deploy:mytask`)
- Add `--pretend` option to console commands to only display the commands that would be executed

------------

### Changelog

### 0.3.1

- Added `--pretend` flag on all commands to print out a list of the commands that would have been executed instead of running them

### 0.3.0

- Added **Task::runInFolder** to run tasks in a specific folder
Expand Down
13 changes: 13 additions & 0 deletions src/Rocketeer/Commands/BaseDeployCommand.php
Expand Up @@ -2,6 +2,7 @@
namespace Rocketeer\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

/**
* A basic deploy command with helpers
Expand All @@ -28,4 +29,16 @@ protected function fireTasksQueue($tasks)
return $this->laravel['rocketeer.tasks']->run($tasks, $this);
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('pretend', 'p', InputOption::VALUE_NONE, 'Returns an array of commands to be executed instead of actually executing them')
);
}

}
4 changes: 2 additions & 2 deletions src/Rocketeer/Commands/DeployDeployCommand.php
Expand Up @@ -43,9 +43,9 @@ public function fire()
*/
protected function getOptions()
{
return array(
return array_merge(parent::getOptions(), array(
array('tests', 't', InputOption::VALUE_NONE, 'Runs the tests on deploy')
);
));
}

}
2 changes: 1 addition & 1 deletion src/Rocketeer/Rocketeer.php
Expand Up @@ -23,7 +23,7 @@ class Rocketeer
*
* @var string
*/
const VERSION = '0.3.0';
const VERSION = '0.3.1';

/**
* Build a new ReleasesManager
Expand Down
5 changes: 5 additions & 0 deletions src/Rocketeer/Tasks/Task.php
Expand Up @@ -103,6 +103,11 @@ public function run($tasks)
$output = null;
$tasks = (array) $tasks;

// Log the commands for pretend
if ($this->command->option('pretend')) {
return $this->command->line(implode(PHP_EOL, $tasks));
}

// Run tasks
$this->remote->run($tasks, function($results) use (&$output) {
$output .= $results;
Expand Down
2 changes: 1 addition & 1 deletion src/Rocketeer/TasksQueue.php
Expand Up @@ -124,7 +124,7 @@ public function getAfter(Task $task)
public function run(array $tasks, $command = null)
{
$this->command = $command;
$queue = $this->buildQueue($tasks);
$queue = $this->buildQueue($tasks);

// Finally we execute the Tasks
foreach ($queue as $task) {
Expand Down
12 changes: 12 additions & 0 deletions tests/TasksTest.php
Expand Up @@ -101,6 +101,7 @@ public function testCanDisplayOutputOfCommandsIfVerbose()
$task = $this->task('Deploy');
$command = $this->getCommand(false);
$command->shouldReceive('option')->with('verbose')->andReturn(true);
$command->shouldReceive('option')->with('pretend')->andReturn(false);
$task->command = $command;

ob_start();
Expand All @@ -110,4 +111,15 @@ public function testCanDisplayOutputOfCommandsIfVerbose()
$this->assertContains('tests', $output);
}

public function testCanPretendToRunTasks()
{
$task = $this->task('Cleanup');
$command = $this->getCommand(false);
$command->shouldReceive('option')->with('pretend')->andReturn(true);
$task->command = $command;

$output = $task->run('ls');
$this->assertEquals('ls', $output);
}

}

0 comments on commit f85d699

Please sign in to comment.