Skip to content

Commit 3c0362f

Browse files
authored
fix jsonPath in ComposerScriptsConfigurator::update (#1011)
* fix jsonPath in ComposerScriptsConfigurator::update * fix jsonPath in ComposerScriptsConfigurator::update (+coding standards fix) * fix jsonPath in ComposerScriptsConfigurator::update * fabbot patch
1 parent a9b6d5d commit 3c0362f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Configurator/ComposerScriptsConfigurator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public function unconfigure(Recipe $recipe, $scripts, Lock $lock)
4949
public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void
5050
{
5151
$json = new JsonFile(Factory::getComposerFile());
52-
$jsonPath = ltrim(str_replace($recipeUpdate->getRootDir(), '', $json->getPath()), '/\\');
52+
$jsonPath = $json->getPath();
53+
if (str_starts_with($jsonPath, $recipeUpdate->getRootDir())) {
54+
$jsonPath = substr($jsonPath, \strlen($recipeUpdate->getRootDir()));
55+
}
56+
$jsonPath = ltrim($jsonPath, '/\\');
5357

5458
$recipeUpdate->setOriginalFile(
5559
$jsonPath,

0 commit comments

Comments
 (0)