forked from Convertio/convertio-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.php
More file actions
35 lines (27 loc) · 681 Bytes
/
compile.php
File metadata and controls
35 lines (27 loc) · 681 Bytes
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
<?php
$FN = "release/convertio";
$PharFN = $FN . ".phar";
if (file_exists($FN)) {
unlink($FN);
}
if (file_exists($PharFN)) {
unlink($PharFN);
}
if (!file_exists(dirname($PharFN))) {
mkdir(dirname($PharFN), 0755, true);
}
$phar = new Phar(
$PharFN,
FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME,
basename($PharFN)
);
$phar->startBuffering();
$defaultStub = $phar->createDefaultStub('cli.php');
$phar->buildFromDirectory(".", '~\.php$~');
$phar->setStub("#!/usr/bin/env php \n" . $defaultStub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
unset($phar);
$phar = null;
rename($PharFN, $FN);
chmod($FN, 0755);