Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing lang folder #39

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading