diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 210e63ff21..00357211e9 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1391,6 +1391,9 @@ class Builds extends Action $listFilesCommand .= ' && ( [ -e ' . \escapeshellarg($file) . ' ] && echo ' . \escapeshellarg($file) . ' || true )'; } + // Static fallback detection only needs to distinguish 0, 1, or 2+ HTML files, so cap the output + $listFilesCommand .= ' && find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2'; + $listFilesCommand .= ' && echo "{APPWRITE_DETECTION_SEPARATOR_END}"'; if (empty($command)) { diff --git a/tests/unit/Functions/BuildsTest.php b/tests/unit/Functions/BuildsTest.php index ff64b80c15..00880dcc1e 100644 --- a/tests/unit/Functions/BuildsTest.php +++ b/tests/unit/Functions/BuildsTest.php @@ -50,6 +50,7 @@ final class BuildsTest extends TestCase $this->assertStringStartsWith('npm run build && echo "{APPWRITE_DETECTION_SEPARATOR_START}"', $command); $this->assertStringContainsString('cd /usr/local/build && cd \'./dist folder\'', (string) $command); $this->assertStringContainsString('( [ -e \'server/entry.mjs\' ] && echo \'server/entry.mjs\' || true )', (string) $command); + $this->assertStringContainsString('find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2', (string) $command); $this->assertStringEndsWith('echo "{APPWRITE_DETECTION_SEPARATOR_END}"', $command); } @@ -59,6 +60,7 @@ final class BuildsTest extends TestCase $this->assertStringStartsWith('echo "{APPWRITE_DETECTION_SEPARATOR_START}"', $command); $this->assertStringContainsString('cd /usr/local/build && ( [ -e \'handler.js\' ] && echo \'handler.js\' || true )', (string) $command); + $this->assertStringContainsString('find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2', (string) $command); } public function testSplitSiteDetectionLogsRemovesDetectionBlock(): void