diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index abdcefc80..a230eda57 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -49,7 +49,11 @@ public function unconfigure(Recipe $recipe, $scripts, Lock $lock) public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void { $json = new JsonFile(Factory::getComposerFile()); - $jsonPath = ltrim(str_replace($recipeUpdate->getRootDir(), '', $json->getPath()), '/\\'); + $jsonPath = $json->getPath(); + if (str_starts_with($jsonPath, $recipeUpdate->getRootDir())) { + $jsonPath = substr($jsonPath, \strlen($recipeUpdate->getRootDir())); + } + $jsonPath = ltrim($jsonPath, '/\\'); $recipeUpdate->setOriginalFile( $jsonPath,