Skip to content

Commit

Permalink
Fix scaffolding path overwriting logic
Browse files Browse the repository at this point in the history
LukeTowers committed Apr 3, 2022
1 parent c1fb3c1 commit 0bb0989
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Scaffold/GeneratorCommand.php
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 0bb0989

Please sign in to comment.