-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace BladeScript\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Filesystem\Filesystem; | ||
use RuntimeException; | ||
|
||
class ScriptClearCommand extends Command | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'script:clear'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Clear all compiled script files'; | ||
|
||
/** | ||
* The filesystem instance. | ||
* | ||
* @var \Illuminate\Filesystem\Filesystem | ||
*/ | ||
protected $files; | ||
|
||
/** | ||
* Create a new config clear command instance. | ||
* | ||
* @param \Illuminate\Filesystem\Filesystem $files | ||
* @return void | ||
*/ | ||
public function __construct(Filesystem $files) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->files = $files; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
* | ||
* @throws \RuntimeException | ||
*/ | ||
public function handle() | ||
{ | ||
$path = $this->laravel['config']['script.compiled']; | ||
|
||
if (!$path) { | ||
throw new RuntimeException('Script path not found.'); | ||
} | ||
|
||
foreach ($this->files->glob("{$path}/*") as $script) { | ||
$this->files->delete($script); | ||
} | ||
|
||
$this->info('Compiled scripts cleared!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters