Skip to content

Commit

Permalink
Merge pull request #37 from BrianHenryIE/Use-getRealPath-for-symlinke…
Browse files Browse the repository at this point in the history
…d-packages

Use getPathname() for symlinked packages
  • Loading branch information
coenjacobs authored May 23, 2020
2 parents 799d3ac + ad32c38 commit 3d28355
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Mover.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace CoenJacobs\Mozart;

use CoenJacobs\Mozart\Composer\Autoload\Autoloader;
use CoenJacobs\Mozart\Composer\Autoload\Classmap;
use CoenJacobs\Mozart\Composer\Autoload\NamespaceAutoloader;
use CoenJacobs\Mozart\Composer\Package;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

class Mover
{
Expand Down Expand Up @@ -97,33 +99,33 @@ public function movePackage(Package $package)

/**
* @param Package $package
* @param $autoloader
* @param $file
* @param $path
* @return mixed
* @param Autoloader $autoloader
* @param SplFileInfo $file
* @param string $path
* @return string
*/
public function moveFile(Package $package, $autoloader, $file, $path = '')
{
if ($autoloader instanceof NamespaceAutoloader) {
$namespacePath = $autoloader->getNamespacePath();
$replaceWith = $this->config->dep_directory . $namespacePath;
$targetFile = str_replace($this->workingDir, $replaceWith, $file->getRealPath());
$targetFile = str_replace($this->workingDir, $replaceWith, $file->getPathname());

$packageVendorPath = '/vendor/' . $package->config->name . '/' . $path;
$packageVendorPath = str_replace('/', DIRECTORY_SEPARATOR, $packageVendorPath);
$targetFile = str_replace($packageVendorPath, '', $targetFile);
} else {
$namespacePath = $package->config->name;
$replaceWith = $this->config->classmap_directory . '/' . $namespacePath;
$targetFile = str_replace($this->workingDir, $replaceWith, $file->getRealPath());
$targetFile = str_replace($this->workingDir, $replaceWith, $file->getPathname());

$packageVendorPath = '/vendor/' . $package->config->name . '/';
$packageVendorPath = str_replace('/', DIRECTORY_SEPARATOR, $packageVendorPath);
$targetFile = str_replace($packageVendorPath, DIRECTORY_SEPARATOR, $targetFile);
}

$this->filesystem->copy(
str_replace($this->workingDir, '', $file->getRealPath()),
str_replace($this->workingDir, '', $file->getPathname()),
$targetFile
);

Expand Down

0 comments on commit 3d28355

Please sign in to comment.