Skip to content

Commit

Permalink
clean command
Browse files Browse the repository at this point in the history
  • Loading branch information
bangnokia committed Mar 23, 2024
1 parent a864897 commit ca5fe74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/Commands/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

namespace BangNokia\Lina\Commands;

class CleanCommand
use BangNokia\Lina\ContentFinder;
use Illuminate\Console\Command;
use Symfony\Component\Finder\Finder;

class CleanCommand extends Command
{
protected $signature = 'clean';

protected $description = 'Clean the built files in public directory';

public function handle(): int
{
$finder = new Finder();

$finder->in(getcwd() . '/public')->files('*.html');

foreach ($finder as $file) {
unlink($file->getRealPath());
}

$this->info('Cleaned the public directory');
}
}
2 changes: 2 additions & 0 deletions app/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ServeCommand extends Command

public function handle()
{
$this->call('clean');

$this->line("<info>Starting development server:</info> http://{$this->host()}:{$this->port()}");

$process = $this->startProcess();
Expand Down

0 comments on commit ca5fe74

Please sign in to comment.