Skip to content

Commit

Permalink
ignore development files on production env
Browse files Browse the repository at this point in the history
Signed-off-by: MarioRadu <[email protected]>
  • Loading branch information
MarioRadu committed Dec 12, 2024
1 parent d45b2e0 commit 385b746
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ jobs:
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

# - name: Setup project
# run: |
# mv config/autoload/local.test.php.dist config/autoload/local.test.php

- name: Collect code coverage with PHPUnit
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml

Expand Down
16 changes: 14 additions & 2 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ function copyFile(array $file): void

function getEnvironment(): string
{
return file_exists('config/development.config.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION;
$composerInstalledJson = 'vendor/composer/installed.json';
if (! file_exists($composerInstalledJson)) {
throw new RuntimeException('Composer installed JSON file not found.');
}

$data = json_decode(file_get_contents($composerInstalledJson), true);
foreach ($data as $package) {
if (! empty($package['dev'])) {
return ENVIRONMENT_DEVELOPMENT;
}
}

return ENVIRONMENT_PRODUCTION;
}

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

echo "Using environment setting : " . getEnvironment() . PHP_EOL;
echo "Using environment setting: " . getEnvironment() . PHP_EOL;

array_walk($files, 'copyFile');

0 comments on commit 385b746

Please sign in to comment.