From 34e40143e982db546f4603ee56d058d3a2ba5315 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 23 Dec 2019 11:15:07 +0100 Subject: [PATCH 1/3] Remove packages from the vendor dir after they are moved --- src/Mover.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Mover.php b/src/Mover.php index df8bd25d..64bc177c 100644 --- a/src/Mover.php +++ b/src/Mover.php @@ -89,6 +89,11 @@ public function movePackage(Package $package) $this->movedPackages[] = $package->config->name; } + + foreach( $this->movedPackages as $movedPackage ) { + $packageDir = $this->workingDir . '/vendor/' . $movedPackage; + $this->filesystem->deleteDir($packageDir); + } } /** From dc14cbae07531fdc7f118c16f263cf107bded668 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 23 Dec 2019 11:29:34 +0100 Subject: [PATCH 2/3] Deleting directories needs to happen on a relative path --- src/Mover.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mover.php b/src/Mover.php index 64bc177c..8f0e934b 100644 --- a/src/Mover.php +++ b/src/Mover.php @@ -91,7 +91,7 @@ public function movePackage(Package $package) } foreach( $this->movedPackages as $movedPackage ) { - $packageDir = $this->workingDir . '/vendor/' . $movedPackage; + $packageDir = '/vendor/' . $movedPackage; $this->filesystem->deleteDir($packageDir); } } From ef690d6ae8a0521898b1a93cec0ec964cd99899d Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 23 Dec 2019 11:40:27 +0100 Subject: [PATCH 3/3] Refactor delete original directories into seperate method --- src/Mover.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Mover.php b/src/Mover.php index 8f0e934b..2c7f115f 100644 --- a/src/Mover.php +++ b/src/Mover.php @@ -90,10 +90,7 @@ public function movePackage(Package $package) $this->movedPackages[] = $package->config->name; } - foreach( $this->movedPackages as $movedPackage ) { - $packageDir = '/vendor/' . $movedPackage; - $this->filesystem->deleteDir($packageDir); - } + $this->deletePackageVendorDirectories(); } /** @@ -130,4 +127,17 @@ public function moveFile(Package $package, $autoloader, $file, $path = '') return $targetFile; } + + /** + * Deletes all the packages that are moved from the /vendor/ directory to + * prevent packages that are prefixed/namespaced from being used or + * influencing the output of the code. They just need to be gone. + */ + protected function deletePackageVendorDirectories() + { + foreach ($this->movedPackages as $movedPackage) { + $packageDir = '/vendor/' . $movedPackage; + $this->filesystem->deleteDir($packageDir); + } + } }