Beispiel #1
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $composerCmd = $this->getApplication()->getConfigValue('bin', 'composer');
     $paramList = $this->getFullParameterList();
     $composerJsonPath = UnixUtility::findFileInDirectortyTree('composer.json');
     if (!empty($composerJsonPath)) {
         $path = dirname($composerJsonPath);
         $this->output->writeln('<comment>Found composer.json directory: ' . $path . '</comment>');
         // Switch to directory of docker-compose.yml
         PhpUtility::chdir($path);
         $command = new CommandBuilder();
         $command->parse($composerCmd);
         if (!empty($paramList)) {
             $command->setArgumentList($paramList);
         }
         $command->executeInteractive();
     } else {
         $this->output->writeln('<error>No composer.json found in tree</error>');
         return 1;
     }
     return 0;
 }
Beispiel #2
0
 /**
  * Build complex task
  *
  * @param array $task Task configuration
  *
  * @return CommandBuilder|CommandBuilderInterface
  */
 protected function buildComplexTask(array $task)
 {
     if (empty($task['type'])) {
         $task['type'] = 'local';
     }
     if (empty($task['command'])) {
         throw new \RuntimeException('Task command is empty');
     }
     // Process task type
     switch ($task['type']) {
         case 'remote':
             // Remote command
             $command = new RemoteCommandBuilder();
             $command->parse($task['command']);
             $command = $this->wrapRemoteCommand($command);
             break;
         case 'local':
             // Local command
             $command = new CommandBuilder();
             $command->parse($task['command']);
             break;
         default:
             throw new \RuntimeException('Unknown task type');
             break;
     }
     return $command;
 }