|
1 |
| -<pre> |
2 | 1 | <?php
|
3 | 2 |
|
4 |
| -function runCommand($command, $shouldHaveOutput = true) |
| 3 | +function outputNice($output) |
5 | 4 | {
|
6 |
| - $output = $return_var = null; |
7 |
| - echo "Running: $command\n"; |
8 |
| - exec($command, $output, $return_var); |
9 |
| - |
10 |
| - if (!$shouldHaveOutput) { |
11 |
| - return; |
| 5 | + if (is_array($output)) { |
| 6 | + foreach ($output as $line) { |
| 7 | + printf("<pre><code>%s</code>", $line); |
| 8 | + } |
| 9 | + } else { |
| 10 | + printf("<pre><code>%s</code>", $output); |
12 | 11 | }
|
| 12 | +} |
13 | 13 |
|
14 |
| - if (empty($output) || !is_array($output)) { |
15 |
| - echo 'Fixtures could not be loaded: '.var_export($return_var, true); |
16 |
| - exit(1); |
17 |
| - } |
18 |
| - echo PHP_EOL; |
19 |
| - echo "Output:\n"; |
20 |
| - foreach ($output as $line) { |
21 |
| - echo $line."\n"; |
22 |
| - } |
| 14 | +$commandFile = __DIR__.'/../bin/reloadFixtures.sh'; |
| 15 | +if (!file_exists($commandFile)) { |
| 16 | + outputNice('File not found at: '.$commandFile); |
23 | 17 | }
|
24 | 18 |
|
25 |
| -runCommand('rm -rf var/cache/prod', false); |
26 |
| -runCommand(__DIR__.'/../bin/console --env=prod doctrine:phpcr:init:dbal --drop --force'); |
27 |
| -runCommand(__DIR__.'/../bin/console --env=prod doctrine:phpcr:repository:init'); |
28 |
| -runCommand(__DIR__.'/../bin/console -v --env=prod doctrine:phpcr:fixtures:load -n'); |
29 |
| -runCommand(__DIR__.'/../bin/console --env=prod cache:warmup -n --no-debug'); |
| 19 | +$returnValue = null; |
| 20 | +$output = []; |
| 21 | +exec($commandFile.' '.__DIR__.'/../', $output, $returnValue); |
| 22 | + |
| 23 | +if (0 !== (int) $returnValue) { |
| 24 | + outputNice('Errors on Execution:'); |
| 25 | + outputNice($output); |
| 26 | + exit($returnValue); |
| 27 | +} else { |
| 28 | + outputNice($output); |
| 29 | + outputNice('Success'); |
| 30 | +} |
0 commit comments