Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont unregister vendors when a package.json is found #819

Merged
merged 1 commit into from Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/PackageJsonSynchronizer.php
Expand Up @@ -69,7 +69,10 @@ private function removePackageJsonLinks(array $packageJson): bool

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

Expand Down
19 changes: 18 additions & 1 deletion tests/PackageJsonSynchronizerTest.php
Expand Up @@ -38,13 +38,13 @@ public function testSynchronizeNoPackage()
{
$this->synchronizer->synchronize([]);

// Should remove existing package references as it has been removed from the lock
$this->assertSame(
[
'name' => 'symfony/fixture',
'devDependencies' => [
'@symfony/stimulus-bridge' => '^1.0.0',
'stimulus' => '^1.1.1',
'@symfony/existing-package' => 'file:vendor/symfony/existing-package/Resources/assets',
],
'browserslist' => [
'defaults',
Expand All @@ -60,6 +60,23 @@ public function testSynchronizeNoPackage()
],
json_decode(file_get_contents($this->tempDir.'/assets/controllers.json'), true)
);

unlink($this->tempDir.'/vendor/symfony/existing-package/Resources/assets/package.json');
$this->synchronizer->synchronize([]);

$this->assertSame(
[
'name' => 'symfony/fixture',
'devDependencies' => [
'@symfony/stimulus-bridge' => '^1.0.0',
'stimulus' => '^1.1.1',
],
'browserslist' => [
'defaults',
],
],
json_decode(file_get_contents($this->tempDir.'/package.json'), true)
);
}

public function testSynchronizeExistingPackage()
Expand Down