Skip to content

Commit dfcc245

Browse files
author
Alexandru Florea
committed
fix: Pass output root through recursion to prevent copy issues
The copyDirectoryRecursive function now correctly tracks the original output directory root to prevent recursion, fixing the issue where only a few files were being copied in production-ready mode.
1 parent dbe326f commit dfcc245

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Services/ObfuscationService.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ protected function createProductionBundle(string $outputDir, array $options): vo
578578
$this->copyDirectoryRecursive(
579579
$this->basePath,
580580
$outputDir,
581+
$outputDir, // Pass original output dir to prevent recursion
581582
$excludeDirs,
582583
$excludeFiles,
583584
$alwaysInclude
@@ -591,6 +592,7 @@ protected function createProductionBundle(string $outputDir, array $options): vo
591592
*
592593
* @param string $source
593594
* @param string $destination
595+
* @param string $outputRoot Original output directory root (to prevent recursion)
594596
* @param array $excludeDirs
595597
* @param array $excludeFiles
596598
* @param array $alwaysInclude
@@ -599,6 +601,7 @@ protected function createProductionBundle(string $outputDir, array $options): vo
599601
protected function copyDirectoryRecursive(
600602
string $source,
601603
string $destination,
604+
string $outputRoot,
602605
array $excludeDirs = [],
603606
array $excludeFiles = [],
604607
array $alwaysInclude = []
@@ -634,7 +637,7 @@ protected function copyDirectoryRecursive(
634637

635638
if ($shouldAlwaysInclude) {
636639
if (is_dir($sourcePath)) {
637-
$this->copyDirectoryRecursive($sourcePath, $destPath, $excludeDirs, $excludeFiles, $alwaysInclude);
640+
$this->copyDirectoryRecursive($sourcePath, $destPath, $outputRoot, $excludeDirs, $excludeFiles, $alwaysInclude);
638641
} else {
639642
copy($sourcePath, $destPath);
640643
}
@@ -652,12 +655,12 @@ protected function copyDirectoryRecursive(
652655
}
653656

654657
// Skip the output directory itself to avoid recursion
655-
if ($sourcePath === $destination || str_starts_with($sourcePath, $destination . DIRECTORY_SEPARATOR)) {
658+
if ($sourcePath === $outputRoot || str_starts_with($sourcePath, $outputRoot . DIRECTORY_SEPARATOR)) {
656659
$shouldExclude = true;
657660
}
658661

659662
if (!$shouldExclude) {
660-
$this->copyDirectoryRecursive($sourcePath, $destPath, $excludeDirs, $excludeFiles, $alwaysInclude);
663+
$this->copyDirectoryRecursive($sourcePath, $destPath, $outputRoot, $excludeDirs, $excludeFiles, $alwaysInclude);
661664
}
662665
} else {
663666
// Skip excluded files

0 commit comments

Comments
 (0)