-
Notifications
You must be signed in to change notification settings - Fork 31
/
pakefile
59 lines (50 loc) · 1.54 KB
/
pakefile
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
<?php
pake_desc('Run the application with local php server');
pake_task('server');
pake_desc('Check the code for psr2 standards');
pake_task('sniff');
pake_desc('Update the contributors in the README');
pake_task('contributors');
pake_desc('Run syntax and unit tests');
pake_task('test');
pake_alias('default', 'test');
function run_server()
{
$host = 'localhost:8008';
pake_echo_comment('Now serving site from http://' . $host);
pake_sh('php -S ' . $host . ' -t public', true);
}
function run_test()
{
pake_echo_comment('Running unit suite');
pake_sh('./vendor/bin/phpunit', true);
}
function run_sniff()
{
pake_echo_comment('Checking files for PSR2');
pake_sh("./vendor/bin/phpcs -p --standard=PSR2 ./public/index.php ./app ./lib");
}
function run_contributors()
{
$startPoint = '## Contributors';
$endPoint = '## Changelog';
$readme = file_get_contents("README.md");
$contributors = explode("\n", shell_exec("git shortlog -s -n"));
$table = "| Author | Commits\n| --- | ---\n";
foreach ($contributors as $contributor) {
if (!trim($contributor)) { continue; }
$contributor = explode("\t", $contributor);
$table .= sprintf(
"| %s | %s |\n",
trim($contributor[1]),
trim($contributor[0])
);
}
$output = preg_replace(
'/('.preg_quote($startPoint).')(.*)('.preg_quote($endPoint).')/si',
"$1\n\n$table\n$3",
$readme
);
file_put_contents("README.md", $output);
}
/* End of file pakefile */