Skip to content

Commit

Permalink
Fix composer globla installation. (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Jan 1, 2017
1 parent 2b1f6b2 commit 15568e6
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ class AnalyzeCommand extends Command
'drupal'
];

private $analyzerBinaries = [
'parallel-lint' => 'jakub-onderka/php-parallel-lint/parallel-lint',
'pdepend' => 'pdepend/pdepend/src/bin/pdepend',
'php-cs-fixer' => 'fabpot/php-cs-fixer/php-cs-fixer',
'phpcbf' =>'squizlabs/php_codesniffer/scripts/phpcbf',
'phpcpd' => 'sebastian/phpcpd/phpcpd',
'phpcs' => 'squizlabs/php_codesniffer/scripts/phpcs',
'phpdcd' => 'sebastian/phpdcd/phpdcd',
'phploc' => 'phploc/phploc/phploc',
'phpmd' => 'phpmd/phpmd/src/bin/phpmd',
'phpunit' => 'phpunit/phpunit/phpunit'
];

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -224,7 +237,7 @@ private function analyzer(SymfonyStyle $io, $analyzer, $files, $config, $project
return;
}
$this->validateBinary('bin/'.$analyzer);
$analizerBinary = $this->calculateBinary($analyzer);
$configFile = $config->getProjectAnalyzerConfigFile($project, $analyzer);
Expand All @@ -240,7 +253,7 @@ private function analyzer(SymfonyStyle $io, $analyzer, $files, $config, $project
$processArguments = [
'php',
$this->directory.'bin/'.$analyzer
$this->directory.$analizerBinary
];
if ($configFile) {
Expand Down Expand Up @@ -335,15 +348,28 @@ public function executeProcess(SymfonyStyle $io, $processArguments, $file, $pref
}
/**
* @param $binaryFile
* @param $analyzer
* @throws \Exception
*/
private function validateBinary($binaryFile)
private function calculateBinary($analyzer)
{
if (!file_exists($this->directory.$binaryFile)) {
throw new Exception(
sprintf('%s do not exist!', $binaryFile)
);
$binaries = [
'/bin/'.$analyzer
];
if (array_key_exists($analyzer, $this->analyzerBinaries)) {
$binaries[] = '/../../'.$this->analyzerBinaries[$analyzer];
$binaries[] = '/../../../'.$this->analyzerBinaries[$analyzer];
}
foreach ($binaries as $binary) {
if (file_exists($this->directory.$binary)) {
return $binary;
}
}
throw new Exception(
sprintf('%s do not exist!', $analyzer)
);
}
}

0 comments on commit 15568e6

Please sign in to comment.