-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev.php
65 lines (55 loc) · 1.82 KB
/
dev.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
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
<?php
error_reporting(E_ALL | E_STRICT);
// If the dependencies aren't installed, we have to bail and offer some help.
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
exit("\nPlease run `composer install` to install dependencies.\n\n");
}
$app = require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Finder\Finder;
$steps = array(
function ($path) {
// TODO: Look for a composer file with a setting for vendor path
if (file_exists($path . '/vendor/bin/pake')) {
return $path . '/vendor/bin/pake';
}
return false;
},
function ($path) {
if (file_exists($path . '/composer.json')) {
$composer = json_decode(file_get_contents('composer.json'));
return isset($composer["config"]["vendor-dir"])
? $composer["config"]["vendor-dir"]
: false;
}
return false;
},
function ($path) {
$finder = new Finder();
$finder->files()->name('pake')->in($path)->notPath('pake-cli');
if (iterator_count($finder)) {
$files = array_keys(iterator_to_array($finder));
return $files[0];
}
return false;
},
function ($path) {
for ($i = 1; $i < 3; $i++) {
$path = realpath($path . '/..');
if ((file_exists($path . '/.hgrc') || file_exists($path . '/.git')) && file_exists($path . '/vendor/bin/pake')) {
return $path . '/vendor/bin/pake';
}
}
return false;
}
);
foreach ($steps as $step) {
$path = $step(defined('IN_PHAR') ? $phar_cwd : getcwd());
if ($path) {
array_shift($argv);
passthru($path . ' --force-tty ' . implode(' ', $argv), $exitCode);
exit($exitCode);
}
}
print "Unable to locate pake";
exit (1);
/* End of dev.php */