Refactoring

This commit is contained in:
gamonoid
2017-09-03 20:39:22 +02:00
parent af40881847
commit a7274d3cfd
5075 changed files with 238202 additions and 16291 deletions

View File

@@ -0,0 +1,126 @@
# Base Tasks
## Exec
Executes shell script. Closes it when running in background mode.
``` php
<?php
$this->taskExec('compass')->arg('watch')->run();
// or use shortcut
$this->_exec('compass watch');
$this->taskExec('compass watch')->background()->run();
if ($this->taskExec('phpunit .')->run()->wasSuccessful()) {
$this->say('tests passed');
}
?>
```
* `background()` Executes command in background mode (asynchronously)
* `timeout($timeout)` Stop command if it runs longer then $timeout in seconds
* `idleTimeout($timeout)` Stops command if it does not output something for a while
* `env(array $env)` Sets the environment variables for the command
* `simulate($context)` {@inheritdoc}
* `dir($dir)` Changes working directory of command
* `printed($arg)` Should command output be printed
* `arg($arg)` Pass argument to executable. Its value will be automatically escaped.
* `args($args)` Pass methods parameters as arguments to executable. Argument values
* `rawArg($arg)` Pass the provided string in its raw (as provided) form as an argument to executable.
* `option($option, $value = null)` Pass option to executable. Options are prefixed with `--` , value can be provided in second parameter.
* `optionList($option, $value = null)` Pass multiple options to executable. Value can be a string or array.
## ExecStack
Execute commands one by one in stack.
Stack can be stopped on first fail if you call `stopOnFail()`.
```php
<?php
$this->taskExecStack()
->stopOnFail()
->exec('mkdir site')
->exec('cd site')
->run();
?>
```
* `$this stopOnFail()`
* `executable($executable)` * `param string` $executable
* `exec($command)` * `param string|string[]` $command
* `stopOnFail($stopOnFail = null)` * `param bool` $stopOnFail
* `result($result)`
* `dir($dir)` Changes working directory of command
* `printed($arg)` Should command output be printed
## ParallelExec
Class ParallelExecTask
``` php
<?php
$this->taskParallelExec()
->process('php ~/demos/script.php hey')
->process('php ~/demos/script.php hoy')
->process('php ~/demos/script.php gou')
->run();
?>
```
* ` timeout(int $timeout)` stops process if it runs longer then `$timeout` (seconds)
* ` idleTimeout(int $timeout)` stops process if it does not output for time longer then `$timeout` (seconds)
* `printed($isPrinted = null)` * `param bool` $isPrinted
* `process($command)` * `param string|\Robo\Contract\CommandInterface` $command
* `timeout($timeout)` * `param int` $timeout
* `idleTimeout($idleTimeout)` * `param int` $idleTimeout
## SymfonyCommand
Executes Symfony Command
``` php
<?php
// Symfony Command
$this->taskSymfonyCommand(new \Codeception\Command\Run('run'))
->arg('suite','acceptance')
->opt('debug')
->run();
// Artisan Command
$this->taskSymfonyCommand(new ModelGeneratorCommand())
->arg('name', 'User')
->run();
?>
```
* `arg($arg, $value)` * `param string` $arg
* `opt($option, $value = null)`
## Watch
Runs task when specified file or dir was changed.
Uses Lurker library.
``` php
<?php
$this->taskWatch()
->monitor('composer.json', function() {
$this->taskComposerUpdate()->run();
})->monitor('src', function() {
$this->taskExec('phpunit')->run();
})->run();
?>
```
* `monitor($paths, $callable)` * `param string|string[]` $paths