/** * Call this with an array of arguments to pass in via the Input object * * @param array $args Array of arguments to inject into the mock Input object before executing */ public function executeCommand($args = []) { $this->setMockInputWithArguments($args); return $this->command->run($this->mocks['input'], $this->mocks['output']); }
$updateRecipesCommand = new \Symfony\Component\Console\Command\Command('update:recipes'); $updateRecipesCommand->setCode(function ($input, $output) use($app) { $run = function ($command) use($app) { $process = new \Symfony\Component\Process\Process('cd ' . $app['recipes.path'] . ' && ' . $command); $process->mustRun(); return $process->getOutput(); }; if (is_file($app['recipes.path'] . '/README.md')) { $output->write($run('git reset --hard origin/master')); $output->write($run('git pull https://github.com/deployphp/recipes.git master 2>&1')); } else { $output->write($run('git clone --depth 1 https://github.com/deployphp/recipes.git . 2>&1')); } }); $console->add($updateRecipesCommand); $scheduleCommand = new \Symfony\Component\Console\Command\Command('schedule'); $scheduleCommand->setCode(function ($input, $output) use($app) { $commands = explode("\n", file_get_contents($app['schedule'])); while (count($commands) > 0) { $command = array_shift($commands); if (in_array($command, ['update:deployer', 'update:documentation', 'update:recipes'], true)) { // Remove same commands. $commands = array_filter($commands, function ($i) use($command) { return $i !== $command; }); $output->write("Running command {$command}.\n"); $process = new \Symfony\Component\Process\Process("php {$app['cli']} {$command}"); $process->run(); file_put_contents(__DIR__ . '/logs/' . $command . '.log', $process->getOutput()); } }