From 6d82e89ff6908974d50802395227481a8ad4c690 Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 16 May 2024 10:52:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=E6=89=93?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Addon.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/application/admin/command/Addon.php b/application/admin/command/Addon.php index 7bca186e..c738c6a0 100644 --- a/application/admin/command/Addon.php +++ b/application/admin/command/Addon.php @@ -201,16 +201,20 @@ class Addon extends Command new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY ); + $addonDir = str_replace(DS, '/', $addonDir); + $excludeDirRegex = "/\/(\.git|\.svn|\.vscode|\.idea|unpackage)\//i"; foreach ($files as $name => $file) { - if (!$file->isDir()) { - $filePath = $file->getRealPath(); - $relativePath = str_replace(DS, '/', substr($filePath, strlen($addonDir))); - if (!in_array($file->getFilename(), ['.git', '.DS_Store', 'Thumbs.db'])) { - $zip->addFile($filePath, $relativePath); - } + $filePath = str_replace(DS, '/', $file->getPathname()); + if ($file->isDir() || preg_match($excludeDirRegex, $filePath)) + continue; + $relativePath = substr($filePath, strlen($addonDir)); + if (!in_array($file->getFilename(), ['.DS_Store', 'Thumbs.db'])) { + $zip->addFile($filePath, $relativePath); } } + $zip->close(); + $output->info("Package Resource Path:" . $addonFile); $output->info("Package Successed!"); break; case 'move':