diff --git a/src/Configurator/CopyFromRecipeConfigurator.php b/src/Configurator/CopyFromRecipeConfigurator.php index b4233111e..e3b8209ae 100644 --- a/src/Configurator/CopyFromRecipeConfigurator.php +++ b/src/Configurator/CopyFromRecipeConfigurator.php @@ -37,18 +37,35 @@ public function unconfigure(Recipe $recipe, $config, Lock $lock) public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void { foreach ($recipeUpdate->getOriginalRecipe()->getFiles() as $filename => $data) { + $filename = $this->resolveTargetFolder($filename, $originalConfig); $recipeUpdate->setOriginalFile($filename, $data['contents']); } $files = []; foreach ($recipeUpdate->getNewRecipe()->getFiles() as $filename => $data) { + $filename = $this->resolveTargetFolder($filename, $newConfig); $recipeUpdate->setNewFile($filename, $data['contents']); $files[] = $this->getLocalFilePath($recipeUpdate->getRootDir(), $filename); } + $recipeUpdate->getLock()->add($recipeUpdate->getPackageName(), ['files' => $files]); } + /** + * @param array $config + */ + private function resolveTargetFolder(string $path, array $config): string + { + foreach ($config as $key => $target) { + if (0 === strpos($path, $key)) { + return $this->options->expandTargetDir($target).substr($path, \strlen($key)); + } + } + + return $path; + } + private function getRemovableFilesFromRecipeAndLock(Recipe $recipe, Lock $lock): array { $lockedFiles = array_unique( diff --git a/tests/Command/UpdateRecipesCommandTest.php b/tests/Command/UpdateRecipesCommandTest.php index 1f09cf9ef..efd16f547 100644 --- a/tests/Command/UpdateRecipesCommandTest.php +++ b/tests/Command/UpdateRecipesCommandTest.php @@ -100,7 +100,7 @@ private function createCommandUpdateRecipes(): CommandTester $rfs = Factory::createRemoteFilesystem($this->io, $composer->getConfig()); $rfs = new ParallelDownloader($this->io, $composer->getConfig(), $rfs->getOptions(), $rfs->isTlsDisabled()); } - $options = new Options(['root-dir' => FLEX_TEST_DIR]); + $options = new Options(['root-dir' => FLEX_TEST_DIR, 'bin-dir' => 'bin/']); $command = new UpdateRecipesCommand( $flex, new Downloader($composer, $this->io, $rfs),