-
Notifications
You must be signed in to change notification settings - Fork 0
/
merger
executable file
·74 lines (56 loc) · 1.79 KB
/
merger
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env php
<?php
declare(strict_types=1);
use Dannecron\CoverageMerger\Command\Exceptions\CommandException;
use Dannecron\CoverageMerger\Command\CloverMergeCommand;
use Dannecron\CoverageMerger\Clover;
if (isset($GLOBALS['_composer_autoload_path'])) {
require_once $GLOBALS['_composer_autoload_path'];
} else {
$knownAutoloadPaths = [
__DIR__ . '/../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
];
foreach ($knownAutoloadPaths as $path) {
if (\file_exists($path)) {
require_once $path;
break;
}
}
unset($knownAutoloadPaths, $path);
}
$appVersion = \getenv('MERGER_VERSION');
if ($appVersion === false) {
$appVersion = 'dev';
}
$app = new \Ahc\Cli\Application('clover-merger', $appVersion);
$app->onException(static function (\Throwable $exception, int $exitCode) use ($app): void {
$io = $app->io();
$io->error($exception->getMessage(), true);
if (($exception instanceof CommandException) === false) {
exit($exitCode);
}
if ($exception->isVerbose() === false) {
exit($exception->getCode());
}
$trace = $exception->getTrace();
$io->table(\array_map(static function (array $traceStep): array {
$methodOrFunc = \array_key_exists('class', $traceStep)
? "{$traceStep['class']}::{$traceStep['function']}"
: $traceStep['function'];
return [
'method/func' => $methodOrFunc,
'file' => "{$traceStep['file']}:{$traceStep['line']}",
];
}, $trace));
exit($exception->getCode());
});
$app->add(
new CloverMergeCommand(
new Clover\Handler(new Clover\Parser()),
new Clover\Renderer(),
$app,
),
);
$app->handle($_SERVER['argv']);