Skip to content

Commit

Permalink
add generateForce method
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Nov 22, 2024
1 parent dd6916f commit 83bd1ab
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/LaravelStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,18 @@ public function download()
return Response::download($this->getPath());
}

/**
* Set stub file move without any copy.
*/
public function generateForce(): bool
{
return $this->generate(true);
}

/**
* Generate stub file.
*/
public function generate(): bool
public function generate(bool $force = false): bool
{
// Check path is valid
if (! File::exists($this->from)) {
Expand All @@ -147,6 +155,11 @@ public function generate(): bool
throw new RuntimeException('The given folder path is not valid.');
}

// Check if files exists and it not force throw exception
if (! File::exists($this->to) && !$force) {
throw new RuntimeException('The destination file does not exist, please enter a valid path.');
}

// Get file content
$content = File::get($this->from);

Expand Down

0 comments on commit 83bd1ab

Please sign in to comment.