From 0bb09894245dc045594df9a7c597bb4a562e924a Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 3 Apr 2022 14:46:47 -0600 Subject: [PATCH] Fix scaffolding path overwriting logic --- src/Scaffold/GeneratorCommand.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Scaffold/GeneratorCommand.php b/src/Scaffold/GeneratorCommand.php index 71d9d844b..b7e1c190f 100644 --- a/src/Scaffold/GeneratorCommand.php +++ b/src/Scaffold/GeneratorCommand.php @@ -162,7 +162,7 @@ public function makeStubs(): void foreach ($stubs as $stub) { $destinationFile = $this->getDestinationForStub($stub); if ($this->files->exists($destinationFile)) { - throw new Exception("Cannot create the {$this->type}, $destinationFile already exists. Pass --force to overwrite existing files."); + throw new Exception("Cannot create the {$this->type}:\r\n$destinationFile already exists.\r\nPass --force to overwrite existing files."); } } } @@ -177,7 +177,10 @@ public function makeStubs(): void */ protected function getDestinationForStub(string $stubName): string { - return $this->getDestinationPath() . '/' . $this->stubs[$stubName]; + return Twig::parse( + $this->getDestinationPath() . '/' . $this->stubs[$stubName], + $this->vars + ); } /** @@ -196,10 +199,9 @@ public function makeStub($stubName) $destinationContent = $this->files->get($sourceFile); /* - * Parse each variable in to the destination content and path + * Parse each variable in to the destination content */ $destinationContent = Twig::parse($destinationContent, $this->vars); - $destinationFile = Twig::parse($destinationFile, $this->vars); $this->makeDirectory($destinationFile);