-
Notifications
You must be signed in to change notification settings - Fork 2
/
component-manager.php
executable file
·39 lines (30 loc) · 1.02 KB
/
component-manager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace ComponentManager;
use Composer\Script\Event;
use Symfony\Component\Filesystem\Filesystem;
class ComponentManager
{
public static function postComposerInstall(Event $event)
{
$config = $event->getComposer()->getConfig();
$componentDir = $config->get('component-dir');
$components = $config->get('components');
$vendorDir = $config->get('vendor-dir');
// if either configuration is empty it's a noop
if (empty($componentDir) || empty($components)) {
return;
}
$componentDir = __DIR__ .'/'. $componentDir;
if (!is_dir($componentDir)) {
mkdir($componentDir);
}
$filesystem = new Filesystem();
foreach ($components as $component) {
$componentSource = $vendorDir .'/'. $component;
if (!is_dir($componentSource)) {
continue;
}
$filesystem->mirror($componentSource, $componentDir .'/'. basename($component));
}
}
}