Skip to content

Commit

Permalink
Fix missing lang folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasss93 committed Mar 14, 2024
1 parent d652229 commit d6d2195
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Console/LarexInitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(): int
return 1;
}

File::put(csv_path(), Utils::getStub($stub));
Utils::filePut(csv_path(), Utils::getStub($stub));

$this->info(csv_path(true).' created successfully.');

Expand Down
9 changes: 9 additions & 0 deletions src/Support/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,13 @@ public static function putJson(string $path, $data): void
JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
File::put($path, Str::finish($content, "\n"));
}

public static function filePut(string $path, string $content): void
{
if (!File::exists(dirname($path))) {
File::makeDirectory(dirname($path), 0755, true, true);
}

File::put($path, $content);
}
}
7 changes: 6 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
File::delete($item);
}
}

//delete lang folder
if (file_exists(lang_path())) {
@rmdir(lang_path());
}
})
->in(__DIR__);

Expand Down Expand Up @@ -81,7 +86,7 @@ function getTestStub(string $name, $eol = "\n"): string
function initFromStub(string $stub, string $file = null): string
{
$filePath = Utils::normalizeDS($file ?? csv_path());
File::put($filePath, getTestStub($stub));
Utils::filePut($filePath, getTestStub($stub));

return $filePath;
}

0 comments on commit d6d2195

Please sign in to comment.