|
24 | 24 | class PackageJsonSynchronizer |
25 | 25 | { |
26 | 26 | private $rootDir; |
| 27 | + private $vendorDirname; |
27 | 28 |
|
28 | | - public function __construct(?string $rootDir) |
| 29 | + public function __construct(string $rootDir, string $vendorDirname) |
29 | 30 | { |
30 | 31 | $this->rootDir = $rootDir; |
| 32 | + $this->vendorDirname = $vendorDirname; |
31 | 33 | } |
32 | 34 |
|
33 | 35 | public function shouldSynchronize(): bool |
@@ -81,7 +83,7 @@ private function addPackageJsonLink(string $phpPackage): bool |
81 | 83 | } |
82 | 84 |
|
83 | 85 | $manipulator = new JsonManipulator(file_get_contents($this->rootDir.'/package.json')); |
84 | | - $manipulator->addSubNode('devDependencies', '@'.$phpPackage, 'file:vendor/'.$phpPackage.$assetsDir); |
| 86 | + $manipulator->addSubNode('devDependencies', '@'.$phpPackage, 'file:'.$this->vendorDirname.'/'.$phpPackage.$assetsDir); |
85 | 87 |
|
86 | 88 | $content = json_decode($manipulator->getContents(), true); |
87 | 89 |
|
@@ -112,7 +114,7 @@ private function registerWebpackResources(array $phpPackages) |
112 | 114 | } |
113 | 115 |
|
114 | 116 | // Register in config |
115 | | - $packageJsonPath = $this->rootDir.'/vendor/'.$phpPackage.$assetsDir.'/package.json'; |
| 117 | + $packageJsonPath = $this->rootDir.'/'.$this->vendorDirname.'/'.$phpPackage.$assetsDir.'/package.json'; |
116 | 118 | $packageJson = (new JsonFile($packageJsonPath))->read(); |
117 | 119 |
|
118 | 120 | foreach ($packageJson['symfony']['controllers'] ?? [] as $controllerName => $defaultConfig) { |
@@ -169,7 +171,7 @@ public function registerPeerDependencies(array $phpPackages) |
169 | 171 | continue; |
170 | 172 | } |
171 | 173 |
|
172 | | - $packageJsonPath = $this->rootDir.'/vendor/'.$phpPackage.$assetsDir.'/package.json'; |
| 174 | + $packageJsonPath = $this->rootDir.'/'.$this->vendorDirname.'/'.$phpPackage.$assetsDir.'/package.json'; |
173 | 175 | $packageJson = (new JsonFile($packageJsonPath))->read(); |
174 | 176 | $versionParser = new VersionParser(); |
175 | 177 |
|
@@ -198,7 +200,7 @@ public function registerPeerDependencies(array $phpPackages) |
198 | 200 | private function resolveAssetsDir(string $phpPackage) |
199 | 201 | { |
200 | 202 | foreach (['/assets', '/Resources/assets'] as $subdir) { |
201 | | - if (file_exists($this->rootDir.'/vendor/'.$phpPackage.$subdir.'/package.json')) { |
| 203 | + if (file_exists($this->rootDir.'/'.$this->vendorDirname.'/'.$phpPackage.$subdir.'/package.json')) { |
202 | 204 | return $subdir; |
203 | 205 | } |
204 | 206 | } |
|
0 commit comments