magallanes/src/Task/BuiltIn/Composer/InstallTask.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2016-12-31 07:52:25 +01:00
<?php
2022-04-10 06:20:03 +02:00
2017-01-04 05:13:13 +01:00
/*
* This file is part of the Magallanes package.
*
* (c) Andrés Montañez <andres@andresmontanez.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2016-12-31 07:52:25 +01:00
namespace Mage\Task\BuiltIn\Composer;
use Symfony\Component\Process\Process;
/**
* Composer Task - Install Vendors
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
2017-04-14 20:24:39 +02:00
class InstallTask extends AbstractComposerTask
2016-12-31 07:52:25 +01:00
{
2022-04-10 06:20:03 +02:00
public function getName(): string
2016-12-31 07:52:25 +01:00
{
return 'composer/install';
}
2022-04-10 06:20:03 +02:00
public function getDescription(): string
2016-12-31 07:52:25 +01:00
{
return '[Composer] Install';
}
2022-04-10 06:20:03 +02:00
public function execute(): bool
2016-12-31 07:52:25 +01:00
{
$options = $this->getOptions();
$cmd = sprintf('%s install %s', $options['path'], $options['flags']);
2016-12-31 07:52:25 +01:00
/** @var Process $process */
2022-04-10 06:20:03 +02:00
$process = $this->runtime->runCommand(trim($cmd), intval($options['timeout']));
2016-12-31 07:52:25 +01:00
return $process->isSuccessful();
}
2022-04-10 06:20:03 +02:00
protected function getComposerOptions(): array
2016-12-31 07:52:25 +01:00
{
2017-04-14 20:24:39 +02:00
return ['flags' => '--optimize-autoloader', 'timeout' => 120];
2016-12-31 07:52:25 +01:00
}
}