forked from consolidation/robo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robo
executable file
·50 lines (46 loc) · 1.62 KB
/
robo
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
#!/usr/bin/env php
<?php
/**
* If we're running from phar load the phar autoload,
* else let the script 'robo' search for the autoloader.
*/
// Hack: \Phar::running() cannot be used reliably here to determine
// if we are running as a phar or not (works when phar is built with
// box, but does not work when phar is built with the Robo phar task.)
// We will use __FILE__ to determine our phar path; however, we cannot
// distinguish whether a __FILE__ of "/path/robo" is this file, or a
// 'robo.phar' that has been renamed to 'robo'. We will use the file
// size to differentiate.
// Recommendation: Use box to build your phar. See https://github.com/g1a/starter
$isPhar = (filesize(__FILE__) > 500000);
// Non-phar autoloader paths
$candidates = [
__DIR__.'/vendor/autoload.php',
__DIR__.'/../../autoload.php',
__DIR__.'/../autoload.php',
];
// Use our phar alias path
if ($isPhar) {
array_unshift($candidates, 'phar://robo.phar/vendor/autoload.php');
}
$autoloaderPath = false;
foreach ($candidates as $candidate) {
if (file_exists($candidate)) {
$autoloaderPath = $candidate;
break;
}
}
if (!$autoloaderPath) {
die("Could not find autoloader. Run 'composer install'.");
}
$classLoader = require $autoloaderPath;
$configFilePath = getenv('ROBO_CONFIG') ?: getenv('HOME') . '/.robo/robo.yml';
$runner = new \Robo\Runner();
$runner
->setRelativePluginNamespace('Robo\Plugin')
->setSelfUpdateRepository('consolidation/robo')
->setConfigurationFilename($configFilePath)
->setEnvConfigPrefix('ROBO')
->setClassLoader($classLoader);
$statusCode = $runner->execute($_SERVER['argv']);
exit($statusCode);