Files
Magallanes/src/Task/BuiltIn/Deploy/Tar/CleanupTask.php
T

49 lines
1.2 KiB
PHP
Raw Normal View History

2016-12-31 03:52:25 -03:00
<?php
/*
* 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.
*/
2017-01-14 22:36:15 -03:00
namespace Mage\Task\BuiltIn\Deploy\Tar;
2016-12-31 03:52:25 -03:00
2017-01-07 01:53:57 -03:00
use Mage\Task\Exception\ErrorException;
2016-12-31 03:52:25 -03:00
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
2017-01-14 22:36:15 -03:00
* Tar Task - Delete temporal Tar
2016-12-31 03:52:25 -03:00
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
class CleanupTask extends AbstractTask
{
public function getName()
{
2017-01-14 22:36:15 -03:00
return 'deploy/tar/cleanup';
2016-12-31 03:52:25 -03:00
}
public function getDescription()
{
2017-01-14 22:36:15 -03:00
return '[Deploy] Cleanup Tar file';
2016-12-31 03:52:25 -03:00
}
public function execute()
{
2017-01-11 22:22:21 -03:00
if (!$this->runtime->getEnvOption('releases', false)) {
2017-01-01 16:39:22 -03:00
throw new ErrorException('This task is only available with releases enabled', 40);
2016-12-31 03:52:25 -03:00
}
2017-01-14 22:36:15 -03:00
$tarLocal = $this->runtime->getVar('tar_local');
2016-12-31 03:52:25 -03:00
2017-01-14 22:36:15 -03:00
$cmdDeleteTar = sprintf('rm %s', $tarLocal);
2016-12-31 03:52:25 -03:00
/** @var Process $process */
2017-01-14 22:36:15 -03:00
$process = $this->runtime->runLocalCommand($cmdDeleteTar);
2017-01-03 09:11:44 -03:00
return $process->isSuccessful();
2016-12-31 03:52:25 -03:00
}
}