Commit d0d99e93 authored by Nicolas Widart's avatar Nicolas Widart

Add remove method. add output handler

parent 0ec1fe30
<?php namespace Modules\Core\Services; <?php namespace Modules\Core\Services;
use Symfony\Component\Process\Process;
class Composer extends \Illuminate\Foundation\Composer class Composer extends \Illuminate\Foundation\Composer
{ {
protected $outputHandler = null; protected $outputHandler = null;
...@@ -8,12 +10,18 @@ class Composer extends \Illuminate\Foundation\Composer ...@@ -8,12 +10,18 @@ class Composer extends \Illuminate\Foundation\Composer
/** /**
* Enable real time output of all commands. * Enable real time output of all commands.
* *
* @param $handler * @param $command
* @return void * @return void
*/ */
public function enableOutput($handler) public function enableOutput($command)
{ {
$this->output = $handler; $this->output = function ($type, $buffer) use ($command) {
if (Process::ERR === $type) {
$command->info(trim('[ERR] > '.$buffer));
} else {
$command->info(trim('> '.$buffer));
}
};
} }
/** /**
...@@ -57,4 +65,14 @@ class Composer extends \Illuminate\Foundation\Composer ...@@ -57,4 +65,14 @@ class Composer extends \Illuminate\Foundation\Composer
$process->setCommandLine(trim($this->findComposer() . ' require ' . $package)); $process->setCommandLine(trim($this->findComposer() . ' require ' . $package));
$process->run($this->output); $process->run($this->output);
} }
public function remove($package)
{
if (!is_null($package)) {
$package = '"' . $package . '"';
}
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer() . ' remove ' . $package));
$process->run($this->output);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment