generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
6 changed files
with
105 additions
and
7 deletions.
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
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,44 @@ | ||
<?php | ||
|
||
namespace Msamgan\LaravelEnvKeysChecker\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class EnvInGitIgnoreCommand extends Command | ||
{ | ||
public $signature = 'env:in-git-ignore'; | ||
|
||
public $description = 'Check if .env file is in .gitignore file.'; | ||
|
||
public function handle(): int | ||
{ | ||
$gitIgnoreFile = base_path('.gitignore'); | ||
|
||
if (! file_exists($gitIgnoreFile)) { | ||
$this->error('!! .gitignore file not found.'); | ||
|
||
return self::FAILURE; | ||
} | ||
|
||
$gitIgnoreContent = array_map('trim', file($gitIgnoreFile)); | ||
|
||
$filesToCheck = config('env-keys-checker.gitignore_files', ['.env']); | ||
|
||
$missingFiles = collect(); | ||
collect($filesToCheck)->each(function ($file) use ($gitIgnoreContent, $missingFiles) { | ||
if (! in_array($file, $gitIgnoreContent)) { | ||
$missingFiles->push($file); | ||
} | ||
}); | ||
|
||
if ($missingFiles->isEmpty()) { | ||
$this->info('=> All files are present in .gitignore file.'); | ||
|
||
return self::SUCCESS; | ||
} | ||
|
||
$this->error('!! ' . $missingFiles->implode(', ') . ' file(s) not found in .gitignore file.'); | ||
|
||
return self::FAILURE; | ||
} | ||
} |
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