Pull request review fixes
This commit is contained in:
parent
2476086f7c
commit
f6d1896096
|
@ -3,9 +3,8 @@
|
|||
namespace PHPCI\Helper;
|
||||
|
||||
use \PHPCI\Logging\BuildLogger;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class BaseCommandExecutor implements CommandExecutor
|
||||
abstract class BaseCommandExecutor implements CommandExecutor
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Logging\BuildLogger
|
||||
|
@ -98,30 +97,5 @@ class BaseCommandExecutor implements CommandExecutor
|
|||
* @param string $binary
|
||||
* @return null|string
|
||||
*/
|
||||
public function findBinary($binary)
|
||||
{
|
||||
$binaryPath = null;
|
||||
|
||||
if (is_string($binary)) {
|
||||
$binary = array($binary);
|
||||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
$this->logger->log("Looking for binary: " . $bin, LogLevel::DEBUG);
|
||||
// Check project root directory:
|
||||
if (is_file($this->rootDir . $bin)) {
|
||||
$this->logger->log("Found in root: " . $bin, LogLevel::DEBUG);
|
||||
$binaryPath = $this->rootDir . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check Composer bin dir:
|
||||
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;
|
||||
}
|
||||
}
|
||||
return $binaryPath;
|
||||
}
|
||||
}
|
||||
abstract public function findBinary($binary);
|
||||
}
|
|
@ -2,18 +2,8 @@
|
|||
|
||||
namespace PHPCI\Helper;
|
||||
|
||||
use \PHPCI\Logging\BuildLogger;
|
||||
|
||||
interface CommandExecutor
|
||||
{
|
||||
/**
|
||||
* @param BuildLogger $logger
|
||||
* @param string $rootDir
|
||||
* @param bool $quiet
|
||||
* @param bool $verbose
|
||||
*/
|
||||
public function __construct(BuildLogger $logger, $rootDir, &$quiet = false, &$verbose = false);
|
||||
|
||||
/**
|
||||
* Executes shell commands. Accepts multiple arguments the first
|
||||
* is the template and everything else is inserted in. c.f. sprintf
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PHPCI\Helper;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class UnixCommandExecutor extends BaseCommandExecutor
|
||||
{
|
||||
/**
|
||||
|
@ -11,21 +13,32 @@ class UnixCommandExecutor extends BaseCommandExecutor
|
|||
*/
|
||||
public function findBinary($binary)
|
||||
{
|
||||
$binaryPath = parent::findBinary($binary);
|
||||
if (is_null($binaryPath)) {
|
||||
$binaryPath = null;
|
||||
|
||||
if (is_string($binary)) {
|
||||
$binary = array($binary);
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
$findCmdResult = trim(shell_exec('which ' . $bin));
|
||||
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;
|
||||
}
|
||||
|
||||
if (!empty($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
$findCmdResult = trim(shell_exec('which ' . $bin));
|
||||
if (!empty($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $binaryPath;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PHPCI\Helper;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class WindowsCommandExecutor extends BaseCommandExecutor
|
||||
{
|
||||
/**
|
||||
|
@ -11,21 +13,32 @@ class WindowsCommandExecutor extends BaseCommandExecutor
|
|||
*/
|
||||
public function findBinary($binary)
|
||||
{
|
||||
$binaryPath = parent::findBinary($binary);
|
||||
if (is_null($binaryPath)) {
|
||||
$binaryPath = null;
|
||||
|
||||
if (is_string($binary)) {
|
||||
$binary = array($binary);
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
$findCmdResult = trim(shell_exec('where ' . $bin));
|
||||
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;
|
||||
}
|
||||
|
||||
if (!empty($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
$findCmdResult = trim(shell_exec('where ' . $bin));
|
||||
if (!empty($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $binaryPath;
|
||||
|
|
Loading…
Reference in a new issue