-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.php
More file actions
31 lines (25 loc) · 1.11 KB
/
build.php
File metadata and controls
31 lines (25 loc) · 1.11 KB
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
<?php
// Delete all PHAR files in current directory
foreach (glob('build/*.phar') as $file) {
unlink($file);
}
if(!is_dir('build')) {
mkdir('build');
}
// Loop through all directories and create PHAR files
$folders = scandir('.');
foreach ($folders as $folder) {
if (is_dir($folder) && $folder != '.' && $folder != '..') {
if(file_exists($folder.'/plugin.json') == false) {
print 'Skipping '.$folder.' (no plugin.json)'.PHP_EOL;
continue;
}
$config = json_decode(file_get_contents($folder.'/plugin.json'), true);
print 'Building '.$config['name'].'-'.$config['version'].'.phar'.PHP_EOL;
$phar = new Phar("build/".$config['name'].'-'.$config['version'].'.phar', 0, $folder.'/build/'.$config['name'].'-'.$config['version'].'.phar');
$phar->buildFromDirectory($folder.'/');
$phar->setDefaultStub($config['main']['namespace'].'/'.$config['main']['class'].'.php', $config['main']['namespace'].'/'.$config['main']['class'].'.php');
$phar->setAlias($config['name'].'-'.$config['version'].'.phar');
$phar->stopBuffering();
}
}