From d2bdf58045b8d2fe8ceba9c65545a746e385d296 Mon Sep 17 00:00:00 2001 From: Pascal Thormeier Date: Mon, 2 Oct 2017 12:31:58 +0200 Subject: [PATCH] Add error message if composer install fails Fixes issue https://github.com/botman/studio-addons/issues/7 --- composer.json | 3 ++- src/Composer.php | 2 +- src/Console/Commands/BotManInstallDriver.php | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 68d4726..a5bef75 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "botman/botman": "~2.0", "illuminate/support": "~5.4.0|~5.5.0", "illuminate/console": "~5.4.0|~5.5.0", - "thecodingmachine/discovery": "^1.2" + "thecodingmachine/discovery": "^1.2", + "symfony/process": "^3.3" }, "require-dev": { "phpunit/phpunit": "~5.0", diff --git a/src/Composer.php b/src/Composer.php index 2581772..143d60c 100644 --- a/src/Composer.php +++ b/src/Composer.php @@ -18,6 +18,6 @@ public function install($package, callable $callback) $process->setCommandLine(trim($this->findComposer().' require '.$package)); - $process->run($callback); + $process->mustRun($callback); } } diff --git a/src/Console/Commands/BotManInstallDriver.php b/src/Console/Commands/BotManInstallDriver.php index b748f0a..ae4a995 100644 --- a/src/Console/Commands/BotManInstallDriver.php +++ b/src/Console/Commands/BotManInstallDriver.php @@ -5,6 +5,7 @@ use GuzzleHttp\Client; use BotMan\Studio\Composer; use Illuminate\Console\Command; +use Symfony\Component\Process\Exception\ProcessFailedException; class BotManInstallDriver extends Command { @@ -75,9 +76,15 @@ public function handle() $this->info('Installing driver "'.$driver['name'].'"'); - $this->composer->install('botman/driver-'.$installDriver, function ($type, $data) { - $this->info($data); - }); + try { + $this->composer->install('botman/driver-'.$installDriver, function ($type, $data) { + $this->info($data); + }); + } catch (ProcessFailedException $e) { + $this->error('Unable to install driver "'.$driver['name'].'":'); + $this->error($e->getMessage()); + exit(1); + } $this->info('Successfully installed driver "'.$driver['name'].'"'); }