-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpakefile.php
65 lines (53 loc) · 1.77 KB
/
pakefile.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
// force usage of local pake
$_self_path = realpath($_SERVER['PHP_SELF']);
$_newstyle_local = dirname(__FILE__).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'pake';
if ($_self_path != $_newstyle_local) {
$php_exec = (isset($_SERVER['_']) and substr($_SERVER['_'], -4) != 'pake') ? $_SERVER['_'] : 'php';
$args = '';
if ($_SERVER['argc'] > 1) {
array_shift($_SERVER['argv']); // removing pake.php
$args_arr = array_map('escapeshellarg', $_SERVER['argv']);
$args = ' '.implode(' ', $args_arr);
}
$force_tty = '';
if (defined('PAKE_FORCE_TTY') or (DIRECTORY_SEPARATOR != '\\' and function_exists('posix_isatty') and @posix_isatty(STDOUT))) {
$force_tty = ' --force-tty';
}
pake_echo_comment("oops… you're using installed pake. restarting with local version…");
pake_sh(escapeshellarg($php_exec).' '.escapeshellarg($_newstyle_local).$force_tty.$args, true);
die();
} else {
pake_echo_comment("using local version of pake. good!");
}
/* registration */
pake_import('simpletest');
pake_task('phar');
pake_task('foo');
/**
* Demo-task
*
* @param string $task
* @param string $args
* @return bool
* @author Alexey Zakhlestin
*/
function run_foo($task, $args)
{
$age = pake_input('How old are you?');
pake_echo_comment("You are ".$age);
// throw new Exception('test');
}
/**
* create an executable PHAR-archive of Pake
*
* @return bool
* @author Alexey Zakhlestin
*/
function run_phar()
{
$finder = pakeFinder::type('any')
->ignore_version_control()
->name('phar-stub.php', '*.class.php', 'autoload.php', 'cli_init.php', 'pakeFunction.php', 'sfYaml*.php');
pakeArchive::createPharArchive($finder, dirname(__FILE__), 'pake.phar', 'phar-stub.php', null, true);
}