Skip to content

Commit 53d6115

Browse files
aarondfrancisclaude
andcommitted
Address CodeRabbit review feedback for Local.php
- Normalize trailing slashes when comparing repository paths - Add warning and create dependency if soloterm/screen not in require - Use str_ends_with for more precise repository filtering 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent bec93c8 commit 53d6115

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Console/Commands/Local.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ protected function link(array $composer, string $composerPath): int
6262
$composer['repositories'] = [];
6363
}
6464

65-
// Check if path repository already exists
65+
// Check if path repository already exists (normalize trailing slashes)
6666
$hasPathRepo = false;
67+
$normalizedPath = rtrim($path, '/');
6768
foreach ($composer['repositories'] as $repo) {
68-
if (isset($repo['type']) && $repo['type'] === 'path' && isset($repo['url']) && $repo['url'] === $path) {
69+
if (isset($repo['type']) && $repo['type'] === 'path' && isset($repo['url']) && rtrim($repo['url'], '/') === $normalizedPath) {
6970
$hasPathRepo = true;
7071
break;
7172
}
@@ -83,9 +84,10 @@ protected function link(array $composer, string $composerPath): int
8384
}
8485

8586
// Update screen dependency to @dev
86-
if (isset($composer['require']['soloterm/screen'])) {
87-
$composer['require']['soloterm/screen'] = '@dev';
87+
if (!isset($composer['require']['soloterm/screen'])) {
88+
$this->warn('soloterm/screen not found in require section. Adding it now.');
8889
}
90+
$composer['require']['soloterm/screen'] = '@dev';
8991

9092
// Write back
9193
if (!$this->writeComposer($composer, $composerPath)) {
@@ -111,8 +113,13 @@ protected function revert(array $composer, string $composerPath): int
111113
return true;
112114
}
113115

114-
// Remove if it looks like a screen path
115-
return !isset($repo['url']) || !str_contains($repo['url'], 'screen');
116+
// Remove only if the path ends with 'screen' or 'screen/'
117+
if (!isset($repo['url'])) {
118+
return true;
119+
}
120+
$normalizedUrl = rtrim($repo['url'], '/');
121+
122+
return !str_ends_with($normalizedUrl, 'screen');
116123
}));
117124

118125
// Remove empty repositories array

0 commit comments

Comments
 (0)