From e9f579cdfdc873231a9c04abee83dbf9d60499e3 Mon Sep 17 00:00:00 2001 From: Milwad Date: Fri, 5 Apr 2024 22:13:43 +0330 Subject: [PATCH] add `moveStub` method --- src/LaravelStub.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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);