Allow the binary finder to use the project's composer.json file
- Load JSON file and get bin-dir value: https://getcomposer.org/doc/articles/vendor-binaries.md - Update finder behaviour to avoid code duplication Signed-off-by: Stéphane HULARD <s.hulard@chstudio.fr>
This commit is contained in:
parent
4a7495a75d
commit
8e23dee03a
5 changed files with 78 additions and 78 deletions
|
|
@ -9,45 +9,10 @@
|
|||
|
||||
namespace PHPCI\Helper;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class UnixCommandExecutor extends BaseCommandExecutor
|
||||
{
|
||||
/**
|
||||
* Find a binary required by a plugin.
|
||||
* @param string $binary
|
||||
* @return null|string
|
||||
*/
|
||||
public function findBinary($binary)
|
||||
protected function findGlobalBinary($binary)
|
||||
{
|
||||
$binaryPath = null;
|
||||
|
||||
if (is_string($binary)) {
|
||||
$binary = array($binary);
|
||||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
$this->logger->log("Looking for binary: " . $bin, LogLevel::DEBUG);
|
||||
|
||||
if (is_file($this->rootDir . $bin)) {
|
||||
$this->logger->log("Found in root: " . $bin, LogLevel::DEBUG);
|
||||
$binaryPath = $this->rootDir . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_file($this->rootDir . 'vendor/bin/' . $bin)) {
|
||||
$this->logger->log("Found in vendor/bin: " . $bin, LogLevel::DEBUG);
|
||||
$binaryPath = $this->rootDir . 'vendor/bin/' . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
$findCmdResult = trim(shell_exec('which ' . $bin));
|
||||
if (!empty($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $binaryPath;
|
||||
return trim(shell_exec('which ' . $binary));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue