From d11bbb0f527764336c7ed8c72616ac5180b9a5f4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 4 May 2021 10:18:17 +0200 Subject: [PATCH] AssetLoader: Allow to make copies of assets --- AssetLoader.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/AssetLoader.php b/AssetLoader.php index d32a33a..066eb77 100644 --- a/AssetLoader.php +++ b/AssetLoader.php @@ -7,8 +7,10 @@ class AssetLoader 'asset/css' => 'vendor/fortawesome/font-awesome/css/fontawesome.css' ]; - public static function update() + public static function update(Composer\Script\Event $event) { + $copy = in_array('copy-assets', $event->getArguments(), true); + if (is_dir('asset')) { // Check for removed files $fs = new Composer\Util\Filesystem(); @@ -48,7 +50,11 @@ class AssetLoader if ($asset->isDir()) { mkdir($relativePath, 0755, true); } elseif ($asset->isFile()) { - symlink($asset->getPathname(), $relativePath); + if ($copy) { + copy($asset->getPathname(), $relativePath); + } else { + symlink($asset->getPathname(), $relativePath); + } } } } @@ -79,7 +85,11 @@ class AssetLoader '/\\' )]); if (! file_exists($relativePath) && $awesomeFile->isFile()) { - symlink($awesomeFile->getPathname(), $relativePath); + if ($copy) { + copy($awesomeFile->getPathname(), $relativePath); + } else { + symlink($awesomeFile->getPathname(), $relativePath); + } } } }