Skip to content

Commit

Permalink
use new Platform methods in Install command
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjektGopher committed Aug 1, 2023
1 parent 0220123 commit 2a49908
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Facades\File;
use LaravelZero\Framework\Commands\Command;
use ProjektGopher\Whisky\Hook;
use ProjektGopher\Whisky\Platform;
use ProjektGopher\Whisky\Whisky;

class Install extends Command
Expand All @@ -13,9 +14,15 @@ class Install extends Command

protected $description = 'Install git hooks';

public function __construct(
public Platform $platform,
) {
parent::__construct();
}

public function handle(): int
{
if (! $this->gitIsInitialized()) {
if ($this->platform->gitIsNotInitialized()) {
$this->error('Git has not been initialized in this project, aborting...');

return Command::FAILURE;
Expand Down Expand Up @@ -62,7 +69,7 @@ public function handle(): int
}
});

if (! Whisky::isWindows()) {
if ($this->platform->isNotWindows()) {
if ($this->option('verbose')) {
$this->info('Verifying hooks are executable...');
}
Expand All @@ -74,9 +81,4 @@ public function handle(): int

return Command::SUCCESS;
}

private function gitIsInitialized(): bool
{
return File::exists(Whisky::cwd('.git'));
}
}

0 comments on commit 2a49908

Please sign in to comment.