Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Apr 21, 2019
1 parent 5c8a09d commit c47975d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions build.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
if (!file_exists('vendor')) {
include 'install.php';
}

function removeIgnored(string $dir, array &$entries, array $ignore)
{
Expand Down Expand Up @@ -117,6 +120,4 @@ function run(string $base, array $dirs, string $filename, array $ignore, array $
'vendor/psr',
];

exec('php test.php');

run(__DIR__, ['vendor', 'src'], 'api.php', $ignore, $priority);
19 changes: 14 additions & 5 deletions patch.php → install.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php

function runDir(string $base, string $dir): int
if (!file_exists('composer.phar')) {
$composer = file_get_contents('https://getcomposer.org/composer.phar');
file_put_contents('composer.phar', $composer);
}
if (!file_exists('vendor')) {
exec('php composer.phar install');
exec('php patch.php');
}

function patchDir(string $base, string $dir): int
{
$count = 0;
$entries = scandir($dir);
Expand All @@ -10,7 +19,7 @@ function runDir(string $base, string $dir): int
}
$filename = "$base/$dir/$entry";
if (is_dir($filename)) {
$count += runDir($base, "$dir/$entry");
$count += patchDir($base, "$dir/$entry");
}
}
foreach ($entries as $entry) {
Expand All @@ -32,12 +41,12 @@ function runDir(string $base, string $dir): int
return $count;
}

function run(string $base, array $dirs)
function patch(string $base, array $dirs)
{
$start = microtime(true);
$count = 0;
foreach ($dirs as $dir) {
$count += runDir($base, $dir);
$count += patchDir($base, $dir);
}
$end = microtime(true);
$time = ($end - $start) * 1000;
Expand All @@ -46,4 +55,4 @@ function run(string $base, array $dirs)
}
}

run(__DIR__, ['vendor']);
patch(__DIR__, ['vendor']);
7 changes: 1 addition & 6 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
use Tqdev\PhpCrudApi\RequestFactory;
use Tqdev\PhpCrudApi\ResponseUtils;

if (!file_exists('composer.phar')) {
$composer = file_get_contents('https://getcomposer.org/composer.phar');
file_put_contents('composer.phar', $composer);
}
if (!file_exists('vendor')) {
exec('php composer.phar install');
include 'install.php';
}
exec('php patch.php');

require 'vendor/autoload.php';

Expand Down

0 comments on commit c47975d

Please sign in to comment.