2016-12-31 07:52:25 +01:00
|
|
|
<?php
|
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;
|
|
|
|
use Mage\Task\AbstractTask;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Composer Task - Install Vendors
|
|
|
|
*
|
|
|
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
|
|
|
*/
|
|
|
|
class InstallTask extends AbstractTask
|
|
|
|
{
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'composer/install';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription()
|
|
|
|
{
|
|
|
|
return '[Composer] Install';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
$options = $this->getOptions();
|
2017-02-11 05:48:26 +01:00
|
|
|
$cmd = sprintf('%s install %s', $options['path'], $options['flags']);
|
2016-12-31 07:52:25 +01:00
|
|
|
|
|
|
|
/** @var Process $process */
|
2017-03-08 22:35:36 +01:00
|
|
|
$process = $this->runtime->runCommand(trim($cmd), $options['timeout']);
|
2016-12-31 07:52:25 +01:00
|
|
|
|
|
|
|
return $process->isSuccessful();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
|
|
|
$options = array_merge(
|
2017-03-08 22:35:36 +01:00
|
|
|
['path' => 'composer', 'flags' => '--optimize-autoloader', 'timeout' => 120],
|
2017-02-03 08:43:24 +01:00
|
|
|
$this->runtime->getMergedOption('composer'),
|
2016-12-31 07:52:25 +01:00
|
|
|
$this->options
|
|
|
|
);
|
|
|
|
|
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|