diff --git a/src/LaravelStub.php b/src/LaravelStub.php index 3ce8bd5..714a8d3 100644 --- a/src/LaravelStub.php +++ b/src/LaravelStub.php @@ -43,6 +43,13 @@ class LaravelStub */ protected array $replaces; + /** + * The stub file move or not. + * + * @var bool + */ + protected bool $moveStub = false; + /** * Set stub path. */ @@ -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. */ @@ -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);