Running artisan twig:clean outputs a simple error string on failure, but doesn't actually return a non-zero integer as is conventionally the case for console commands. This makes it a lot harder to check for successful execution both on the command line (in a script) and when running commands as part of an application like Artisan::call('twig:clean').
The solution is fairly simple. In Command\Clean::fire add two return statements like:
<?php
// ...
if ($files->exists($cacheDir)) {
$this->error('Twig cache failed to be cleaned');
return 1;
} else {
$this->info('Twig cache cleaned');
return 0;
}
Running
artisan twig:clean
outputs a simple error string on failure, but doesn't actually return a non-zero integer as is conventionally the case for console commands. This makes it a lot harder to check for successful execution both on the command line (in a script) and when running commands as part of an application likeArtisan::call('twig:clean')
.The solution is fairly simple. In
Command\Clean::fire
add two return statements like: