Skip to content

Commit a6e80fb

Browse files
Dont unregister vendors when a package.json is found
1 parent 6ffb71a commit a6e80fb

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/PackageJsonSynchronizer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ private function removePackageJsonLinks(array $packageJson): bool
6969

7070
foreach (['dependencies' => $jsDependencies, 'devDependencies' => $jsDevDependencies] as $key => $packages) {
7171
foreach ($packages as $name => $version) {
72-
if ('@' !== $name[0] || 0 !== strpos($version, 'file:') || false === strpos($version, '/assets')) {
72+
if ('@' !== $name[0] || 0 !== strpos($version, 'file:'.$this->vendorDir.'/') || false === strpos($version, '/assets')) {
73+
continue;
74+
}
75+
if (file_exists($this->rootDir.'/'.substr($version, 5).'/package.json')) {
7376
continue;
7477
}
7578

tests/PackageJsonSynchronizerTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public function testSynchronizeNoPackage()
3838
{
3939
$this->synchronizer->synchronize([]);
4040

41-
// Should remove existing package references as it has been removed from the lock
4241
$this->assertSame(
4342
[
4443
'name' => 'symfony/fixture',
4544
'devDependencies' => [
4645
'@symfony/stimulus-bridge' => '^1.0.0',
4746
'stimulus' => '^1.1.1',
47+
'@symfony/existing-package' => 'file:vendor/symfony/existing-package/Resources/assets',
4848
],
4949
'browserslist' => [
5050
'defaults',
@@ -60,6 +60,23 @@ public function testSynchronizeNoPackage()
6060
],
6161
json_decode(file_get_contents($this->tempDir.'/assets/controllers.json'), true)
6262
);
63+
64+
unlink($this->tempDir.'/vendor/symfony/existing-package/Resources/assets/package.json');
65+
$this->synchronizer->synchronize([]);
66+
67+
$this->assertSame(
68+
[
69+
'name' => 'symfony/fixture',
70+
'devDependencies' => [
71+
'@symfony/stimulus-bridge' => '^1.0.0',
72+
'stimulus' => '^1.1.1',
73+
],
74+
'browserslist' => [
75+
'defaults',
76+
],
77+
],
78+
json_decode(file_get_contents($this->tempDir.'/package.json'), true)
79+
);
6380
}
6481

6582
public function testSynchronizeExistingPackage()

0 commit comments

Comments
 (0)