Skip to content

Commit

Permalink
Fixed missed directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ravuthz authored Jan 14, 2025
1 parent d696d0d commit 86d75c1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Console/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function writeError($template, ...$args)

public function createTemplate(string $type, string $path, $template)
{
$this->createDirectory($path);

if (file_exists(base_path($path))) {
$this->writeError('%s [%s] already exists.', $type, $path);
}
Expand All @@ -33,6 +35,8 @@ public function createTemplate(string $type, string $path, $template)

public function updateTemplate(string $type, string $path, $template)
{
$this->createDirectory($path);

if (!file_exists(base_path($path))) {
$this->writeError('%s [%s] not exists.', $type, $path);
}
Expand All @@ -41,4 +45,15 @@ public function updateTemplate(string $type, string $path, $template)
$this->writeInfo('%s [%s] updated successfully.', $type, $path);
}

}
public function createDirectory($path)
{
$directory = dirname(base_path($path));

if (!is_dir($directory)) {
if (!mkdir($directory, 0755, true) && !is_dir($directory)) {
$this->writeError('Failed to create directory: %s', $directory);
return;
}
}
}
}

0 comments on commit 86d75c1

Please sign in to comment.