Skip to content

Commit

Permalink
add moveStub method
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Apr 5, 2024
1 parent 2375874 commit e9f579c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/LaravelStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class LaravelStub
*/
protected array $replaces;

/**
* The stub file move or not.
*
* @var bool
*/
protected bool $moveStub = false;

/**
* Set stub path.
*/
Expand Down Expand Up @@ -105,6 +112,16 @@ public function replaces(array $replaces): static
return $this;
}

/**
* Set stub file move without any copy.
*/
public function moveStub(): static
{
$this->moveStub = true;

return $this;
}

/**
* Download the stub file.
*/
Expand Down Expand Up @@ -141,8 +158,11 @@ public function generate(): bool
// Get correct path
$path = $this->getPath();

// Move file
File::move($this->from, $path);
if ($this->moveStub) {
File::move($this->from, $path); // Move the file
} else {
File::copy($this->from, $path); // Copy the file
}

// Put content and write on file
File::put($path, $content);
Expand Down

0 comments on commit e9f579c

Please sign in to comment.