diff --git a/src/Composer/ComposerPackage.php b/src/Composer/ComposerPackage.php index 309b9c27..9f8c14bb 100644 --- a/src/Composer/ComposerPackage.php +++ b/src/Composer/ComposerPackage.php @@ -120,6 +120,9 @@ public function __construct(Composer $composer, array $overrideAutoload = null) if (file_exists($vendorDirectory . DIRECTORY_SEPARATOR . $this->packageName)) { $this->relativePath = $this->packageName; $this->packageAbsolutePath = realpath($vendorDirectory . DIRECTORY_SEPARATOR . $this->packageName) . DIRECTORY_SEPARATOR; + // If the package is symlinked, the path will be outside the working directory. + } elseif (0 !== strpos($absolutePath, getcwd()) && 1 === preg_match('/.*\/([^\/]*\/[^\/]*)\/[^\/]*/', $vendorDirectory, $output_array)) { + $this->relativePath = $output_array[1]; } elseif (1 === preg_match('/.*\/([^\/]*\/[^\/]*)\/composer.json/', $composerJsonFileAbsolute, $output_array)) { // Not every package gets installed to a folder matching its name (crewlabs/unsplash). $this->relativePath = $output_array[1]; diff --git a/src/FileEnumerator.php b/src/FileEnumerator.php index b0d4e14f..2ab44c77 100644 --- a/src/FileEnumerator.php +++ b/src/FileEnumerator.php @@ -127,15 +127,8 @@ public function compileFileList(): void foreach ($namespace_relative_paths as $namespace_relative_path) { if (is_file($packagePath . $namespace_relative_path)) { - // $finder->files()->name($file)->in($source_path); - $sourceAbsoluteFilepath = $packagePath . $namespace_relative_path; - - $outputRelativeFilepath = str_replace($prefixToRemove, '', $sourceAbsoluteFilepath); - $outputRelativeFilepath = preg_replace('#[\\\/]+#', DIRECTORY_SEPARATOR, $outputRelativeFilepath); - if (is_null($outputRelativeFilepath)) { - throw new \Exception('Error replacing directory separator in outputRelativeFilepath.'); - } + $outputRelativeFilepath = $dependency->getRelativePath() . DIRECTORY_SEPARATOR . $namespace_relative_path; $file = array( 'dependency' => $dependency,