Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Toolkit/src/Recipe/Recipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
*/
final class Recipe
{
/**
* @var list<File>|null
*/
private ?array $files = null;

/**
* @param non-empty-string $name
* @param non-empty-string $absolutePath
Expand Down Expand Up @@ -102,12 +107,22 @@ public function getExamples(): array
*/
public function getFiles(): iterable
{
// This used to be a generator, so every consumer re-walked the recipe
// directories from disk. Several of them iterate the same recipe more
// than once while rendering or installing it.
if (null !== $this->files) {
return $this->files;
}

$files = [];
foreach ($this->manifest->copyFiles as $source => $destination) {
$finder = new Finder()->in(Path::join($this->absolutePath, $source))->sortByName()->files();

foreach ($finder as $file) {
yield new File(Path::join($source, $file->getRelativePathname()), Path::join($destination, $file->getRelativePathname()));
$files[] = new File(Path::join($source, $file->getRelativePathname()), Path::join($destination, $file->getRelativePathname()));
}
}

return $this->files = $files;
}
}
Loading