1
0
Fork 0

Fix exit code 5 on composer require/create-project command (#11616)

pull/11617/head
Uladzimir Tsykun 2023-09-03 10:54:07 +02:00 committed by GitHub
parent d221d5c69a
commit 90cbb144b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -136,6 +136,7 @@ EOT
->setApcuAutoloader($apcu, $apcuPrefix) ->setApcuAutoloader($apcu, $apcuPrefix)
->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input)) ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
->setAudit($input->getOption('audit')) ->setAudit($input->getOption('audit'))
->setErrorOnAudit($input->getOption('audit'))
->setAuditFormat($this->getAuditFormat($input)) ->setAuditFormat($this->getAuditFormat($input))
; ;

View File

@ -170,6 +170,8 @@ class Installer
protected $executeOperations = true; protected $executeOperations = true;
/** @var bool */ /** @var bool */
protected $audit = true; protected $audit = true;
/** @var bool */
protected $errorOnAudit = false;
/** @var Auditor::FORMAT_* */ /** @var Auditor::FORMAT_* */
protected $auditFormat = Auditor::FORMAT_SUMMARY; protected $auditFormat = Auditor::FORMAT_SUMMARY;
@ -402,7 +404,7 @@ class Installer
$repoSet->addRepository($repo); $repoSet->addRepository($repo);
} }
return $auditor->audit($this->io, $repoSet, $packages, $this->auditFormat, true, $this->config->get('audit')['ignore'] ?? []) > 0 ? self::ERROR_AUDIT_FAILED : 0; return $auditor->audit($this->io, $repoSet, $packages, $this->auditFormat, true, $this->config->get('audit')['ignore'] ?? []) > 0 && $this->errorOnAudit ? self::ERROR_AUDIT_FAILED : 0;
} catch (TransportException $e) { } catch (TransportException $e) {
$this->io->error('Failed to audit '.$target.' packages.'); $this->io->error('Failed to audit '.$target.' packages.');
if ($this->io->isVerbose()) { if ($this->io->isVerbose()) {
@ -1422,6 +1424,19 @@ class Installer
return $this; return $this;
} }
/**
* Should exit with status code 5 on audit error
*
* @param bool $errorOnAudit
* @return Installer
*/
public function setErrorOnAudit(bool $errorOnAudit): self
{
$this->errorOnAudit = $errorOnAudit;
return $this;
}
/** /**
* What format should be used for audit output? * What format should be used for audit output?
* *