public function execute(InputInterface $input, OutputInterface $output)
 {
     $arguments = $input->getArguments();
     $filesManager = new FilesManager();
     $arguments = $this->validateArguments($arguments);
     $commandLine = 'bash ' . realpath(__DIR__ . $this->scriptsDir) . '/getChanged.sh -n "' . $arguments['version'] . '"';
     $commandLine = $this->generateParameters($commandLine, $arguments);
     $process = new Process($commandLine);
     $process->run(function ($type, $buffer) use($output) {
         if (Process::ERR === $type) {
             $output->writeln('<error>' . $buffer . '</error>');
         } else {
             $output->writeln('<info>' . $buffer . '</info>');
         }
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     if ($filesManager->createJsonFileFromSchema(realpath(__DIR__ . FilesManager::SCHEMA_FILE_PATH), $arguments)) {
         return true;
     }
     return false;
 }
Esempio n. 2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $arguments = $input->getArguments();
     $filesManager = new FilesManager();
     if (empty($arguments['target'])) {
         $arguments['target'] = realpath(__DIR__ . $this->target) . '/';
     }
     if (isset($arguments['exclude']) && empty($arguments['exclude'])) {
         $arguments['exclude'] = array();
     }
     if (!file_exists($arguments['target'])) {
         throw new \Exception($arguments['target'] . ' not found.', 1);
     }
     if (!is_writable($arguments['target'])) {
         throw new \Exception($arguments['target'] . ' is not writable.', 1);
     }
     $commandLine = 'bash ' . realpath(__DIR__ . $this->scriptsDir) . '/getChanged.sh -n "' . $arguments['version'] . '"';
     if (isset($arguments['comparePath']) && !empty($arguments['comparePath'])) {
         $commandLine .= ' -d ' . $arguments['comparePath'];
     } else {
         $commandLine .= ' -d ./';
     }
     if (isset($arguments['source']) && !empty($arguments['source'])) {
         $commandLine .= ' -s ' . $arguments['source'];
     }
     if (isset($arguments['target']) && !empty($arguments['target'])) {
         $commandLine .= ' -t ' . $arguments['target'];
     }
     if (!empty($arguments['exclude'])) {
         $commandLine .= ' -e ' . '"' . implode('|', $arguments['exclude']) . '"';
     }
     $commandLine .= ' -c ' . $arguments['reference'];
     $process = new Process($commandLine);
     $process->run(function ($type, $buffer) use($output) {
         if (Process::ERR === $type) {
             $output->writeln('<error>' . $buffer . '</error>');
         } else {
             $output->writeln('<info>' . $buffer . '</info>');
         }
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     if ($filesManager->createJsonFileFromSchema(realpath(__DIR__ . $this->schemaPath), $arguments)) {
         return true;
     }
     return false;
 }