Maurits van der Schee 5 years ago
parent
commit
c47975d87d
3 changed files with 18 additions and 13 deletions
  1. 3
    2
      build.php
  2. 14
    5
      install.php
  3. 1
    6
      test.php

+ 3
- 2
build.php View File

@@ -1,4 +1,7 @@
1 1
 <?php
2
+if (!file_exists('vendor')) {
3
+    include 'install.php';
4
+}
2 5
 
3 6
 function removeIgnored(string $dir, array &$entries, array $ignore)
4 7
 {
@@ -117,6 +120,4 @@ $priority = [
117 120
     'vendor/psr',
118 121
 ];
119 122
 
120
-exec('php test.php');
121
-
122 123
 run(__DIR__, ['vendor', 'src'], 'api.php', $ignore, $priority);

patch.php → install.php View File

@@ -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']);

+ 1
- 6
test.php View File

@@ -5,14 +5,9 @@ use Tqdev\PhpCrudApi\Database\GenericDB;
5 5
 use Tqdev\PhpCrudApi\RequestFactory;
6 6
 use Tqdev\PhpCrudApi\ResponseUtils;
7 7
 
8
-if (!file_exists('composer.phar')) {
9
-    $composer = file_get_contents('https://getcomposer.org/composer.phar');
10
-    file_put_contents('composer.phar', $composer);
11
-}
12 8
 if (!file_exists('vendor')) {
13
-    exec('php composer.phar install');
9
+    include 'install.php';
14 10
 }
15
-exec('php patch.php');
16 11
 
17 12
 require 'vendor/autoload.php';
18 13
 

Loading…
Cancel
Save