Skip to content

Commit

Permalink
exclude mac files
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsWiegers committed Jun 6, 2023
1 parent 15c1232 commit cb29034
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Console/Commands/CheckIfTranslationsAreAllThereCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CheckIfTranslationsAreAllThereCommand extends Command
* @var string
*/
protected $signature = 'translations:check {--directory=} {--excludedDirectories=none}';

/**
* The console command description.
*
Expand All @@ -34,6 +33,8 @@ class CheckIfTranslationsAreAllThereCommand extends Command
*/
public array $realLines = [];

const EXCLUDE_MAC_FILES = ['.DS_Store'];

/**
* Create a new command instance.
*
Expand Down Expand Up @@ -88,6 +89,10 @@ public function handle()
continue;
}

if(in_array($languageWithMissingFile, self::EXCLUDE_MAC_FILES)) {
continue;
}

$missingFiles[] = 'The language ' . $languageWithMissingFile . ' (' . $directory . '/' . $languageWithMissingFile . ') is missing the file ( ' . $fileName . ' )';
}
$this->handleFile($languageDir, $langFile);
Expand Down Expand Up @@ -118,6 +123,10 @@ public function handle()
}
}

if(in_array($language, self::EXCLUDE_MAC_FILES)) {
continue;
}

if(Str::contains($fileKey, $languages)) {
$missing[] = $language . '.' . $keyWithoutFile;
}else {
Expand Down
23 changes: 23 additions & 0 deletions tests/Tests/Unit/Console/Commands/CheckExcludeMacFilesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Console\Commands;

use Tests\TestCase;

class CheckExcludeMacFilesTest extends TestCase
{
private string $languagesDir = 'tests/resources/lang/exclude_mac_files';
public function setUp(): void
{
parent::setUp();
}

public function testItSkipsTotallyFineIfDSStoreExists()
{
$command = $this->artisan('translations:check', [
'--directory' => $this->languagesDir . '/ds-store'
]);

$command->assertExitCode(0);
}
}
Empty file.
5 changes: 5 additions & 0 deletions tests/resources/lang/exclude_mac_files/ds-store/en/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'test_key' => 'test_value',
];

0 comments on commit cb29034

Please sign in to comment.