Exemplo n.º 1
0
 /**
  * Executes the command.
  *
  * @param InputInterface  $input  An input stream
  * @param OutputInterface $output An output stream
  *
  * @return int null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dryRun = $input->getOption('dry-run');
     $checkOnly = $input->getOption('check-only');
     $mode = Licenser::MODE_NORMAL;
     if ($checkOnly) {
         $mode = Licenser::MODE_CHECK_ONLY;
     } elseif ($dryRun) {
         $mode = Licenser::MODE_DRY_RUN;
     }
     $logger = new ProcessLogger($output);
     $logger->startProcess($mode);
     if ($configFile = $this->extractConfigFile($input)) {
         foreach (ConfigFactory::createFromConfigFile($configFile, $input) as $config) {
             $this->buildLicenser($config, $logger)->process($mode);
         }
     } else {
         $config = ConfigFactory::createFromCommandLine($input);
         $this->buildLicenser($config, $logger)->process($mode);
     }
     $logger->finishProcess();
     if ($mode === Licenser::MODE_CHECK_ONLY && $logger->countAdditions() + $logger->countUpdates() > 0) {
         return 1;
     }
     return 0;
 }
Exemplo n.º 2
0
 public function testCreateFromConfigFileMultiFinder()
 {
     $config = Config::create()->setLicense(file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'src', 'licenses', 'default'])))->setFinderBuilder(FinderBuilder::create(['in' => [realpath($this->tempDir)], 'name' => '*.php']));
     $configJs = Config::create()->setLicense(file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'src', 'licenses', 'default'])))->setFinderBuilder(FinderBuilder::create(['in' => [realpath(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'src')], 'name' => '*.js']));
     $configFile = $this->buildYml(['finders' => ['php' => ['in' => 'licenser'], 'javascript' => ['in' => 'src', 'name' => '*.js']]]);
     self::assertEquals([$config, $configJs], ConfigFactory::createFromConfigFile($configFile));
 }