magallanes/src/Task/BuiltIn/Deploy/TarGz/CleanupTask.php

49 lines
1.2 KiB
PHP
Raw Normal View History

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