Skip to content

Commit

Permalink
AssetLoader: Allow to make copies of assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed May 4, 2021
1 parent ffd1e1d commit d11bbb0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions AssetLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -48,7 +50,11 @@ public static function update()
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);
}
}
}
}
Expand Down Expand Up @@ -79,7 +85,11 @@ public static function update()
'/\\'
)]);
if (! file_exists($relativePath) && $awesomeFile->isFile()) {
symlink($awesomeFile->getPathname(), $relativePath);
if ($copy) {
copy($awesomeFile->getPathname(), $relativePath);
} else {
symlink($awesomeFile->getPathname(), $relativePath);
}
}
}
}
Expand Down

0 comments on commit d11bbb0

Please sign in to comment.