Skip to content

Commit

Permalink
Add error message if composer install fails
Browse files Browse the repository at this point in the history
Fixes issue botman#7
  • Loading branch information
thormeier committed Oct 2, 2017
1 parent f7cf5a6 commit d2bdf58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function install($package, callable $callback)

$process->setCommandLine(trim($this->findComposer().' require '.$package));

$process->run($callback);
$process->mustRun($callback);
}
}
13 changes: 10 additions & 3 deletions src/Console/Commands/BotManInstallDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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'].'"');
}
Expand Down

0 comments on commit d2bdf58

Please sign in to comment.