Skip to content

Commit 385b746

Browse files
committed
ignore development files on production env
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
1 parent d45b2e0 commit 385b746

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/codecov.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ jobs:
4444
- name: Install dependencies with composer
4545
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4646

47-
# - name: Setup project
48-
# run: |
49-
# mv config/autoload/local.test.php.dist config/autoload/local.test.php
50-
5147
- name: Collect code coverage with PHPUnit
5248
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
5349

bin/composer-post-install-script.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ function copyFile(array $file): void
2626

2727
function getEnvironment(): string
2828
{
29-
return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION;
29+
$composerInstalledJson = 'vendor/composer/installed.json';
30+
if (! file_exists($composerInstalledJson)) {
31+
throw new RuntimeException('Composer installed JSON file not found.');
32+
}
33+
34+
$data = json_decode(file_get_contents($composerInstalledJson), true);
35+
foreach ($data as $package) {
36+
if (! empty($package['dev'])) {
37+
return ENVIRONMENT_DEVELOPMENT;
38+
}
39+
}
40+
41+
return ENVIRONMENT_PRODUCTION;
3042
}
3143

3244
// when adding files to the below array the `source` and `destination` paths must be relative to the project root folder
@@ -49,6 +61,6 @@ function getEnvironment(): string
4961
],
5062
];
5163

52-
echo "Using environment setting : " . getEnvironment() . PHP_EOL;
64+
echo "Using environment setting: " . getEnvironment() . PHP_EOL;
5365

5466
array_walk($files, 'copyFile');

0 commit comments

Comments
 (0)