|
@@ -1,6 +1,15 @@
|
1
|
1
|
<?php
|
2
|
2
|
|
3
|
|
-function runDir(string $base, string $dir): int
|
|
3
|
+if (!file_exists('composer.phar')) {
|
|
4
|
+ $composer = file_get_contents('https://getcomposer.org/composer.phar');
|
|
5
|
+ file_put_contents('composer.phar', $composer);
|
|
6
|
+}
|
|
7
|
+if (!file_exists('vendor')) {
|
|
8
|
+ exec('php composer.phar install');
|
|
9
|
+ exec('php patch.php');
|
|
10
|
+}
|
|
11
|
+
|
|
12
|
+function patchDir(string $base, string $dir): int
|
4
|
13
|
{
|
5
|
14
|
$count = 0;
|
6
|
15
|
$entries = scandir($dir);
|
|
@@ -10,7 +19,7 @@ function runDir(string $base, string $dir): int
|
10
|
19
|
}
|
11
|
20
|
$filename = "$base/$dir/$entry";
|
12
|
21
|
if (is_dir($filename)) {
|
13
|
|
- $count += runDir($base, "$dir/$entry");
|
|
22
|
+ $count += patchDir($base, "$dir/$entry");
|
14
|
23
|
}
|
15
|
24
|
}
|
16
|
25
|
foreach ($entries as $entry) {
|
|
@@ -32,12 +41,12 @@ function runDir(string $base, string $dir): int
|
32
|
41
|
return $count;
|
33
|
42
|
}
|
34
|
43
|
|
35
|
|
-function run(string $base, array $dirs)
|
|
44
|
+function patch(string $base, array $dirs)
|
36
|
45
|
{
|
37
|
46
|
$start = microtime(true);
|
38
|
47
|
$count = 0;
|
39
|
48
|
foreach ($dirs as $dir) {
|
40
|
|
- $count += runDir($base, $dir);
|
|
49
|
+ $count += patchDir($base, $dir);
|
41
|
50
|
}
|
42
|
51
|
$end = microtime(true);
|
43
|
52
|
$time = ($end - $start) * 1000;
|
|
@@ -46,4 +55,4 @@ function run(string $base, array $dirs)
|
46
|
55
|
}
|
47
|
56
|
}
|
48
|
57
|
|
49
|
|
-run(__DIR__, ['vendor']);
|
|
58
|
+patch(__DIR__, ['vendor']);
|